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] handle nullable parameters with None added to allowed_values #2034

Merged
merged 3 commits into from
Feb 9, 2019

Conversation

rienafairefr
Copy link
Contributor

PR checklist

  • Read the contribution guidelines.
  • 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: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.
    @wing328 @taxpon @frol @mbohlool @cbornet @kenjones-cisco

Description of the PR

I think this fixes #1997, if a parameter is nullable, then None should be an allowed value.

I ran `./bin/saples/python-petstore-all.sh' it created a bunch of changes that don't seem related, not sure why.

@rienafairefr rienafairefr changed the title handle nullable parameters with None added to allowed_values [Python] handle nullable parameters with None added to allowed_values Jan 31, 2019
@@ -108,6 +108,9 @@ class {{classname}}(object):
{{#isEnum}}
{{#isContainer}}
allowed_values = [{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501
Copy link
Contributor

@spacether spacether Feb 2, 2019

Choose a reason for hiding this comment

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

Why not instead, in each allowed_values definitions add something like?

allowed_values = [{{#isNullable}}None, {{/isNullable}}{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]  # noqa: E501

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, would probably be cleaner. I wasn't sure, feared to add too much commas or something :-)

@spacether
Copy link
Contributor

I ran `./bin/saples/python-petstore-all.sh' it created a bunch of changes that don't seem related, not sure why.

It created a bunch of changes because it runs:
./bin/python-asyncio-petstore.sh
./bin/python-petstore.sh
./bin/python-tornado-petstore.sh

@wing328
Copy link
Member

wing328 commented Feb 4, 2019

I ran `./bin/samples/python-petstore-all.sh' it created a bunch of changes that don't seem related, not sure why.

We only added python scripts to the ensure up-to-date script recenlty so don't worry about those additional changes. Please commit those changes and we'll review accordingly.

@rienafairefr
Copy link
Contributor Author

@spacether @wing328 PR updated, thanks for the review guys

@wing328 wing328 added this to the 4.0.0 milestone Feb 9, 2019
@wing328 wing328 merged commit cf6f102 into OpenAPITools:master Feb 9, 2019
@rienafairefr rienafairefr deleted the required-nullable-enum branch February 9, 2019 23:11
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
…OpenAPITools#2034)

* handle nullable parameters with None added to allowed_values

* update samples

* spec for testing enum with null/nullable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] nullable enum property
3 participants