-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[Python] handle nullable parameters with None added to allowed_values #2034
Conversation
@@ -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 |
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.
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
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.
Yeah, would probably be cleaner. I wasn't sure, feared to add too much commas or something :-)
It created a bunch of changes because it runs: |
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. |
240caf9
to
f6b5e5f
Compare
f6b5e5f
to
16563f5
Compare
@spacether @wing328 PR updated, thanks for the review guys |
…OpenAPITools#2034) * handle nullable parameters with None added to allowed_values * update samples * spec for testing enum with null/nullable
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\
.master
,. Default:3.4.x
,4.0.x
master
.@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.