swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

Feature/success code responses

Open ignaciomolina opened this issue 7 years ago • 12 comments

PR checklist

  • [x] Read the contribution guidelines.
  • [x] Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if 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\.
  • [ ] Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • [x] Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

@bbdouglas @JFCote @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger

Description of the PR

  • Add attribute to CodegenOperations to obtain the response code
  • Add response code to Java Play Framework Controller template

ignaciomolina avatar Feb 16 '18 10:02 ignaciomolina

#7583 @JFCote

tzimisce012 avatar Feb 16 '18 10:02 tzimisce012

How is it going? @wing328 :sweat_smile:

ignaciomolina avatar Feb 27 '18 15:02 ignaciomolina

@ignaciomolina let me review tomorrow. Sorry for the delay.

wing328 avatar Feb 27 '18 15:02 wing328

@ignaciomolina the change breaks the Pistache generator:

[main] INFO io.swagger.parser.Swagger20Parser - reading from modules/swagger-codegen/src/test/resources/2_0/petstore.yaml
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /root/src/github.com/swagger-api/swagger-codegen/samples/server/petstore/pistache-server/model/ApiResponse.h
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /root/src/github.com/swagger-api/swagger-codegen/samples/server/petstore/pistache-server/model/ApiResponse.cpp
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /root/src/github.com/swagger-api/swagger-codegen/samples/server/petstore/pistache-server/model/Category.h
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /root/src/github.com/swagger-api/swagger-codegen/samples/server/petstore/pistache-server/model/Category.cpp
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /root/src/github.com/swagger-api/swagger-codegen/samples/server/petstore/pistache-server/model/Order.h
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /root/src/github.com/swagger-api/swagger-codegen/samples/server/petstore/pistache-server/model/Order.cpp
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /root/src/github.com/swagger-api/swagger-codegen/samples/server/petstore/pistache-server/model/Pet.h
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /root/src/github.com/swagger-api/swagger-codegen/samples/server/petstore/pistache-server/model/Pet.cpp
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /root/src/github.com/swagger-api/swagger-codegen/samples/server/petstore/pistache-server/model/Tag.h
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /root/src/github.com/swagger-api/swagger-codegen/samples/server/petstore/pistache-server/model/Tag.cpp
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /root/src/github.com/swagger-api/swagger-codegen/samples/server/petstore/pistache-server/model/User.h
[main] INFO io.swagger.codegen.AbstractGenerator - writing file /root/src/github.com/swagger-api/swagger-codegen/samples/server/petstore/pistache-server/model/User.cpp
Exception in thread "main" java.lang.RuntimeException: Could not process operation:
  Tag: Tag {
	name: user
	description: Operations about user
	externalDocs: io.swagger.models.ExternalDocs@e1e57bab
	extensions:{}}
  Operation: createUser
  Resource: post /user
  Definitions: {Order=io.swagger.models.ModelImpl@6b904c51, Category=io.swagger.models.ModelImpl@ba13e696, User=io.swagger.models.ModelImpl@9db581f0, Tag=io.swagger.models.ModelImpl@d651f3db, Pet=io.swagger.models.ModelImpl@c9d5d174, ApiResponse=io.swagger.models.ModelImpl@16a9e5a9}
  Exception: For input string: "default"
	at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:935)
	at io.swagger.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:814)
	at io.swagger.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:434)
	at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:749)
	at io.swagger.codegen.cmd.Generate.run(Generate.java:285)
	at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)
Caused by: java.lang.NumberFormatException: For input string: "default"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Integer.parseInt(Integer.java:615)
	at io.swagger.codegen.languages.PistacheServerCodegen.fromOperation(PistacheServerCodegen.java:166)
	at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:884)
	... 5 more

For the full log, please click on the link to the Shippable CI job.

wing328 avatar Feb 28 '18 08:02 wing328

I was able to repeat the issue locally by running ./bin/pistache-server-petstore.sh.

wing328 avatar Feb 28 '18 08:02 wing328

Shippable doesn't show me the logs, it says that I have to download it but I don't see any download button

ignaciomolina avatar Feb 28 '18 08:02 ignaciomolina

@ignaciomolina can you try https://app.shippable.com/download/jobConsoles?jobId=5a965e1b9e550508008cef87? You will need to register an account at shippable and log in to obtain a valid token.

wing328 avatar Feb 28 '18 08:02 wing328

@wing328 solved!

ignaciomolina avatar Mar 01 '18 11:03 ignaciomolina

Thanks. I will review tonight.

wing328 avatar Mar 01 '18 11:03 wing328

cc the following technical committees as the change affects multiple generators:

  • Ada: @stcarrez @micheleISEP
  • Apex: @asnelling
  • C++: @ravinikam @stkrwork @fvarose
  • Pistache: @sebymiano

wing328 avatar Mar 01 '18 16:03 wing328

If no further question/feedback, I"ll merge this PR on coming Friday.

wing328 avatar Mar 08 '18 13:03 wing328

@wing328 , it would be great if we could merge this PR :)

@ignaciomolina there is a merge conflict.

edrevo avatar Apr 26 '18 08:04 edrevo