-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[Python] correct return types if multiple responses are defined #7427
[Python] correct return types if multiple responses are defined #7427
Conversation
cc @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01) @arun-nalla (2019/11) @spacether (2019/11) |
@@ -263,6 +280,7 @@ class {{classname}}(object): | |||
post_params=form_params, | |||
files=local_var_files, | |||
response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, # noqa: E501 | |||
response_types_map=response_types_map, |
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.
Rather than using two parameters for return type
- return_type
- response_types_map
how about using a single parameter like:
- return_types which is a map of status code to data type
Please see this similar-to PR which was never finished
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.
@spacether
I ve just removed response_type
Could you check the pr one more time ?
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.
Thank you for using only one parameter. This pr has failing ci testa because the samples need to be regenerated. Can you please regenerate samples with these commands?
mvn clean install
bin/generate_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.
@spacether
I ve just regenerated
I am seeing an uncommitted changes error in Circle. Closing and re opening to kick off CI again. |
@ksvirkou-hubspot thank you for this PR. We are so close!
|
…rator into python/multiple_responses
|
||
response_types_map={ | ||
200: "Pet", | ||
400: "", |
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 these empty mappings be omitted?
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.
Yes it Should be empty
"400": {
"description": "Invalid status value"
}
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.
So then should the value be None for these cases? It looks like that is what we were defaulting to before.
Adding a test that returns a response with an invalid status would verify that this does what you want it to do.
If you want to add that, here is a similar to test that tests sending to and receiving from a server and deserializing.
In it we mock the returned response data and we deserialize into whatever is defined in response_type/response_types_map.
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.
@spacether
done
|
@spacether |
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.
Thank you for the PR. This looks great!
Labeling this as a breaking change with fallback because we are changing the call_api interface
PR checklist
./bin/generate-samples.sh
to update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH.master
Description of the PR
Fixed issue #7426
Also fixes #440