-
Notifications
You must be signed in to change notification settings - Fork 6k
Feature/success code responses #7674
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
base: master
Are you sure you want to change the base?
Feature/success code responses #7674
Conversation
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.
It look good and with proper review from the core team, I think it will be a very good addition to swagger-codegen. We need to make sure to generate the samples of every generator affected by this and make sure they still compile and run test properly.
@@ -158,14 +158,21 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation | |||
CodegenOperation op = super.fromOperation(path, httpMethod, operation, definitions, swagger); | |||
|
|||
if (operation.getResponses() != null && !operation.getResponses().isEmpty()) { | |||
Response methodResponse = findMethodResponse(operation.getResponses()); | |||
Map.Entry<String, Response> methodResponse = findMethodResponse(operation.getResponses()); |
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.
Since your are changing stuff in many other generators, did you make sure to generate all theses generators? Does it create any changes to 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.
this change affects to other generators but only changes code generated for java play framework, because successCode
is used nowhere else
@@ -1975,20 +1975,20 @@ protected void setNonArrayMapProperty(CodegenProperty property, String type) { | |||
* @param responses Swagger Operation's responses | |||
* @return default method response or <tt>null</tt> if not found | |||
*/ | |||
protected Response findMethodResponse(Map<String, Response> responses) { | |||
protected Entry<String, Response> findMethodResponse(Map<String, Response> responses) { |
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.
If I understand your code correctly, this seems to be a change to the CORE of swagger codegen since it change the way we handle return status. At the beginning, I though it was only Play Framework generator that was missing feature to return the good code but since you needed to add stuff in the DefaultCodegen, I guess it was missing from all codegen.
That is making this change request more important and I think that core members should review it too.
@wing328 Can you check this and also tag some core members to review this.
Thanks!
@@ -307,7 +306,7 @@ | |||
"type" : "file" | |||
} ], | |||
"responses" : { | |||
"200" : { | |||
"201" : { |
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'm surprised the json changed... If I'm not mistaken, this is simply a dump from swagger-parser in json format. Why is it now using the 201 code instead of 200. Did I miss something?
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.
Agreed.
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.
my mistake, I did a few tests and I add the file to the commit without notice it
How is it going? @wing328 😅 |
@ignaciomolina let me review tomorrow. Sorry for the delay. |
@ignaciomolina the change breaks the Pistache generator:
For the full log, please click on the link to the Shippable CI job. |
I was able to repeat the issue locally by running |
Shippable doesn't show me the logs, it says that I have to download it but I don't see any download button |
@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 solved! |
Thanks. I will review tonight.
|
cc the following technical committees as the change affects multiple generators:
|
If no further question/feedback, I"ll merge this PR on coming Friday. |
@wing328 , it would be great if we could merge this PR :) @ignaciomolina there is a merge conflict. |
PR checklist
./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\
.3.0.0
branch for changes related to OpenAPI spec 3.0. Default:master
.@bbdouglas @JFCote @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger
Description of the PR