[Python] correct return types if multiple responses are defined #7427
[Python] correct return types if multiple responses are defined #7427spacether merged 9 commits intoOpenAPITools:masterfrom ksvirkou-hubspot:python/multiple_responses
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) |
| 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.
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.
@spacether
I ve just removed response_type
Could you check the pr one more time ?
There was a problem hiding this comment.
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
|
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.
Should these empty mappings be omitted?
There was a problem hiding this comment.
Yes it Should be empty
"400": {
"description": "Invalid status value"
}
There was a problem hiding this comment.
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.
|
@spacether |
spacether
left a comment
There was a problem hiding this comment.
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.shto 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.masterDescription of the PR
Fixed issue #7426
Also fixes #440