Spring-MVC config "j8-async": Uses async servlet & Java 8 interface #1742
Conversation
default This template is mainly for Maven code-gen plugin use-case - when Swagger spec on existing project changes there is no need to manually copy/paste the new functions from the generated client. This will provide a default (empty) implementation to existing impl and user just need to override the stub implementation. Because it generates an interface instead of a concrete stub, an implementation will be needed to actuate a service end-point. And don't forget to put @controller on the implementation!
This comment has been minimized.
This comment has been minimized.
icha024
commented on modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java
in 29b4098
Dec 19, 2015
Use with Maven: <plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.1.5-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/swagger.yaml</inputSpec>
<language>spring-mvc</language>
<configOptions>
<sourceFolder>src/gen/java/main</sourceFolder>
<library>j8-async</library>
</configOptions>
</configuration>
</execution>
</executions>
</plugin> |
@icha024 thanks for the PR but the CI tests failed. Here is the log: https://api.travis-ci.org/jobs/97884873/log.txt?deansi=true Please review and let us know if you need help addressing the issue reported by CI. I would suggest you to add |
The previous patch to allow sub options to spring-mvc had removed the invalid Jersey2 option from spring-mvc codegen, this patch also fixes the associated test.
@wing328 All done |
@icha024 thanks but I don't see |
Added the executable and config file for spring-mvc's j8-async target.
@wing328 bin scripts are now added |
@icha024 when running 'mvn test` in the sample folder, I got the errors with the sample. Here is part of the error message:
Did you get similar error when running I would also suggest updating |
The spring-mvc j8-async code is now located in it's own sample directory with Java 8 enforced via Maven plug-in.
@wing328 The spring-mvc j8-async code is now located in it's own sample directory with Java 8 enforced via Maven plug-in. |
Spring-MVC config "j8-async": Uses async servlet & Java 8 interface
@icha024 If I understand correctly, a concrete class annotated by @controller needs to be added manually or the controller will not be created/scanned. Is that correct ? |
@cbornet Yes that is correct, it's not needed. In hindsight it should've been removed and replaced with a comment instead. BTW, if you are interested in using this with Maven, here's the plugin snippet that might be useful: |
In jaxrs generators the implementation class is generated if it doesn't exists. Would that work with your plugin ? It would be useful for the first generation. |
For the first generation that's ok, but the challenge we have is keeping the spec and code synced when spec changes (often pushed by a different team) - so an interface would work better for that. The 'default' implementation part is a nice to have. |
I mean that in jaxrs, there is an interface and an implementation. When you regenerate, the implementation is not overridden. |
Cool, didn't know that. That should work On Sat, Jun 4, 2016 at 7:53 AM, Christophe Bornet notifications@github.com
|
default
This template is mainly for Maven code-gen plugin use-case - when
Swagger spec on existing project changes there is no need to manually
copy/paste the new functions from the generated client. This will
provide a default (empty) implementation to existing impl and user just
need to override the stub implementation.
Because it generates an interface instead of a concrete stub, an
implementation will be needed to actuate a service end-point. And don't
forget to put @controller on the implementation!