-
Notifications
You must be signed in to change notification settings - Fork 6k
[Java][Spring][Server] fix spring-mvc path enum issue #6890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@MZinchenko thanks for the PR. Please run |
|
Sorry for long time reply. Also when I update java samples, my samples\server\petstore\spring-mvc\pom.xml always going wrong. |
I'll take a look... |
|
I'm doing some tests as well... cc @cbornet |
|
Tests passed via https://circleci.com/gh/swagger-api/swagger-codegen/2594 (after updating Spring Petstore samples) |
|
The samples of this PR are not OK so it's hard to review... |
|
What's wrong in samples?
2017-11-15 18:13 GMT+03:00 Christophe Bornet <notifications@github.com>:
… The samples of this PR are not OK so it's hard to review...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6890 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AfX4bA9CjiFqIFP7kSElRat1ZvB3Rrvsks5s2v16gaJpZM4QSYYw>
.
|
|
There are |
|
I simply ran scripts:
java-petstore.bat
java-petstore-okhttp-gson.bat
java-play-framework-petstore-server.bat
java-vertx-async-petstore-server.bat
java-vertx-rx-petstore-server.bat
spring-mvc-petstore-j8-async-server.bat
spring-mvc-petstore-server.bat
springboot-petstore-server.bat
What can I do to solve this problems?
Annotation @generated <https://github.com/generated> created by default, as
I can see (in my swagger classes it exists too)
2017-11-15 23:49 GMT+03:00 Christophe Bornet <notifications@github.com>:
… There are @generated <https://github.com/generated> annotations
everywhere instead of being hidden, the examples have been removed from
spring controllers, etc...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6890 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AfX4bK9clxAQc5vnBopQ6mtcea7qMISYks5s205JgaJpZM4QSYYw>
.
|
|
The windows scripts are incorrect... |
|
Ok. I fix windows scripts and push it in this PR.
But as I can see there are lot of changes is samples.
There are comment changes and "get => is" at most.
As I can see this is result of changing version from 2.2.3 to 2.3.0.
2017-11-17 1:56 GMT+03:00 Christophe Bornet <notifications@github.com>:
… The windows scripts are incorrect...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6890 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AfX4bNqyXDW_8wYWopXL2S6X7Ned_uZxks5s3L2jgaJpZM4QSYYw>
.
|
| method = RequestMethod.POST) | ||
| default CompletableFuture<ResponseEntity<Void>> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { | ||
| default CompletableFuture<ResponseEntity<Void>> addPet( | ||
| @ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alignment is wrong
| method = RequestMethod.DELETE) | ||
| default CompletableFuture<ResponseEntity<Void>> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) { | ||
| default CompletableFuture<ResponseEntity<Void>> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId | ||
| , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comma should not be here
| method = RequestMethod.GET) | ||
| default CompletableFuture<ResponseEntity<List<Pet>>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status) { | ||
| default CompletableFuture<ResponseEntity<List<Pet>>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status | ||
| ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be on this line
| return new ApiInfoBuilder() | ||
| .title("Swagger Petstore") | ||
| .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\") | ||
| .description("This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The swagger spec used seems different than before. Still an issue with Windows script ?
| method = RequestMethod.GET) | ||
| ResponseEntity<Order> getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId); | ||
| ResponseEntity<Order> getOrderById(@Min(1) @Max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not be on this line
|
Summary, there are some problems:
1) spring-mvc-petstore-server.sh, springboot-petstore-server.sh and other
java shell scripts using
"petstore-with-fake-endpoints-models-for-testing.yaml" but "petstore.yaml".
That's very strange (windows scripts using "petstore.yaml").
2) windows scripts are very outdated. I think, they must be removed or
updated. I can't run shell scripts nativly, but I'll try
3) suddenly new-line problem. I can't understand why new-lines appears
before some params.
I revert my branch changes, but they are still here. I think this
problem is elder or environment aware.
2017-11-17 19:15 GMT+03:00 Christophe Bornet <notifications@github.com>:
… ***@***.**** commented on this pull request.
------------------------------
In samples/server/petstore/spring-mvc-j8-async/src/main/
java/io/swagger/api/PetApi.java
<#6890 (comment)>
:
> @@ -61,7 +61,8 @@
produces = { "application/xml", "application/json" },
consumes = { "application/json", "application/xml" },
method = RequestMethod.POST)
- default CompletableFuture<ResponseEntity<Void>> ***@***.***(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
+ default CompletableFuture<ResponseEntity<Void>> addPet(
***@***.***(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body) {
Alignment is wrong
------------------------------
In samples/server/petstore/spring-mvc-j8-async/src/main/
java/io/swagger/api/PetApi.java
<#6890 (comment)>
:
> @@ -81,7 +82,9 @@
@RequestMapping(value = "/pet/{petId}",
produces = { "application/xml", "application/json" },
method = RequestMethod.DELETE)
- default CompletableFuture<ResponseEntity<Void>> ***@***.***(value = "Pet id to delete",required=true) @PathVariable("petId") Long ***@***.***(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) {
+ default CompletableFuture<ResponseEntity<Void>> ***@***.***(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId
+,
This comma should not be here
------------------------------
In samples/server/petstore/spring-mvc-j8-async/src/main/
java/io/swagger/api/PetApi.java
<#6890 (comment)>
:
> @@ -102,7 +105,8 @@
@RequestMapping(value = "/pet/findByStatus",
produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
- default CompletableFuture<ResponseEntity<List<Pet>>> ***@***.*** @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status) {
+ default CompletableFuture<ResponseEntity<List<Pet>>> ***@***.*** @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status
+) {
This should not be on this line
------------------------------
In samples/server/petstore/spring-mvc-j8-async/src/main/
java/io/swagger/configuration/SwaggerDocumentationConfig.java
<#6890 (comment)>
:
> @@ -17,7 +17,7 @@
ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Swagger Petstore")
- .description("This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\")
+ .description("This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.")
The swagger spec used seems different than before. Still an issue with
Windows script ?
------------------------------
In samples/server/petstore/spring-mvc/src/main/java/io/
swagger/api/StoreApi.java
<#6890 (comment)>
:
> produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
- ResponseEntity<Order> ***@***.***(1) @max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("order_id") Long orderId);
+ ResponseEntity<Order> ***@***.***(1) @max(5) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId
+);
Should not be on this line
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6890 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AfX4bKYozLSOPXr10Dt7S2w8FWXvQTwEks5s3bEmgaJpZM4QSYYw>
.
|
|
Correct and most used scripts are Unix ones. I think the windows scripts have been added as a block without checking each particular languages so that's why there are differences. |
| @@ -1 +1 @@ | |||
| {{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}} | |||
| {{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{#lambdaEscapeDoubleQuote}}{{{value}}}{{/lambdaEscapeDoubleQuote}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}} | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is were the extra line has been added. Remove it and regenerate the samples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You means new line after {{/isPathParam}}?
I already done that and regenerate the samples, but new lines not removed.
Also I revert all changes in my branch and regenerate the samples, but new lines not removed.
As you can see, new lines appears in blocks generated by other templates, not pathParams.mustache only. First of all PetApi.java using bodyParams.mustache for addPet method, but I don't change bodyParams.mustache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed this change and some windows scripts changes, but samples still have some differences
|
Ok. I done update samples under CentOS inside Docker. |
|
@MZinchenko PR merged into master. Thanks for your contribution. When you've time, I wonder if you can contact me via the email address on my Github profile. Thanks. |
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\.3.0.0branch for changes related to OpenAPI spec 3.0. Default:master.Description of the PR
Issue #4680 fixed in proper way