Skip to content
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

Merged
merged 9 commits into from
Oct 3, 2020
Merged

[Python] correct return types if multiple responses are defined #7427

merged 9 commits into from
Oct 3, 2020

Conversation

ksvirkou-hubspot
Copy link
Contributor

@ksvirkou-hubspot ksvirkou-hubspot commented Sep 15, 2020

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./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.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR
Fixed issue #7426
Also fixes #440

@wing328
Copy link
Member

wing328 commented Sep 17, 2020

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,
Copy link
Contributor

@spacether spacether Sep 17, 2020

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

Copy link
Contributor Author

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 ?

Copy link
Contributor

@spacether spacether Sep 21, 2020

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

Copy link
Contributor Author

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

@spacether spacether added this to the 5.0.0 milestone Sep 25, 2020
@spacether
Copy link
Contributor

I am seeing an uncommitted changes error in Circle. Closing and re opening to kick off CI again.
If that does not fix it this needs a rebase on master then mvn clean install and bin/generate_samples

@spacether spacether closed this Sep 25, 2020
@spacether spacether reopened this Sep 25, 2020
@spacether
Copy link
Contributor

@ksvirkou-hubspot thank you for this PR. We are so close!
Can you:

  • rebase you branch on master?
  • mvn clean install
  • bin/generate_samples


response_types_map={
200: "Pet",
400: "",
Copy link
Contributor

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?

Copy link
Contributor Author

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"
}

https://petstore.swagger.io/v2/swagger.json

Copy link
Contributor

@spacether spacether Sep 29, 2020

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spacether
done

@ksvirkou-hubspot
Copy link
Contributor Author

@ksvirkou-hubspot thank you for this PR. We are so close!
Can you:

  • rebase you branch on master?
  • mvn clean install
  • bin/generate_samples

@ksvirkou-hubspot
Copy link
Contributor Author

@ksvirkou-hubspot thank you for this PR. We are so close!
Can you:

  • rebase you branch on master?
  • mvn clean install
  • bin/generate_samples

@spacether
done

Copy link
Contributor

@spacether spacether left a 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

@spacether spacether merged commit 4e5ecf2 into OpenAPITools:master Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants