-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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] fix numeric enum in python flask, aiohttp #5019
Conversation
@@ -116,6 +118,7 @@ class {{classname}}(Model): | |||
{{/isMapContainer}} | |||
{{/isContainer}} | |||
{{^isContainer}} | |||
allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/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.
We are tying to minimize the usage of flake8 E501 and other flake8 opt out lines.
Can you spread this to a multiline statement so we won't need # noqa: E501
?
{{#isContainer}} | ||
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.
We are tying to minimize the usage of flake8 E501 and other flake8 opt out lines.
Can you spread this to a multiline statement so we won't need # noqa: E501?
@@ -109,6 +109,7 @@ class {{classname}}(Model): | |||
{{/isMapContainer}} | |||
{{/isContainer}} | |||
{{^isContainer}} | |||
allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/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.
We are tying to minimize the usage of flake8 E501 and other flake8 opt out lines.
Can you spread this to a multiline statement so we won't need # noqa: E501?
{{#isContainer}} | ||
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.
We are tying to minimize the usage of flake8 E501 and other flake8 opt out lines.
Can you spread this to a multiline statement so we won't need # 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.
Let's do this in a separate PR instead. I'll open an issue to track it to see if anyone has the time to improve it.
(this PR simply plots the fix from the python client template)
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.
Are you suggesting that we remove the E501s in a separate PR? That sounds good.
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.
Created #5030 for tracking.
@@ -32,7 +32,7 @@ paths: | |||
required: true | |||
x-body-name: body | |||
responses: | |||
405: | |||
"405": |
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.
These spec updates are unexpected in this pull review because we did not edit the spec file.
Can you please add the below sample generation files to https://github.com/OpenAPITools/openapi-generator/blob/master/bin/utils/ensure-up-to-date?
- python-aiohttp
- python-flask-python2
- python-flask
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.
Added to ensure-up-to-date.
These scripts are using petstore.yaml (original) but not the fake petstore spec (which has numeric enums)
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.
Can we add a model with numeric enums in petstore.yaml?
That lets us verify this fix in the repo and this PR. Or a java test like I mention below also verifies the fix.
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.
We can update the script to use the fake petstore spec instead (petstore.yaml shouldn't be updated)
When a generator gets mature, we will use fake petstore spec instead of petstore.yaml/json as the generator should be able to handle those edge cases in fake petstore spec.
I'm not sure if these generators can handle the edge cases in fake petstore spec.
I am seeing that our sample spec has numeric enums, including numeric enums in models. If we don't have a spec of this use case, could you add a minimal spec with it?
If we do have a spec with this use case can you use it? |
If you look at the fix, it cannot be tested in the Java class because it uses Later after switching these scripts from petstore.yaml to fake petstore petstore, we can add test(s) in the samples to ensure the output is correct. |
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.
Good point about the testing. This looks good as is.
* 5.0.x: (92 commits) [Rust Server] Handle array of objects inside an object correctly (#5044) [Rust Server] Sanitise enum values (#5042) [Rust Server] Add support for primitive arrays (#5041) [elm] Fix duplicate coder names (#5100) [elm] enum items and parameters (#5051) [elm] Fix decoding empty operation responses (#5055) resolve merge conflicts in VERSION files undo restoring ElmClientCodegenTest.java fix merge conflicts [dart-dio] Various fixes (#5027) Add java code comments based on explanation from Jim Schubert (#5048) Execute ./bin/openapi3/go-experimental-petstore.sh script (#5049) [docs] Sorted doc outputs and clean up duplicated CliOptions (#5046) Add docs/installation.md and docsite index to version update script (#5037) [gradle] consistent use of maven url in gradle files (#5045) Use HTTPS Maven URL in Kotlin meta generator (#5043) [Python] fix numeric enum in python flask, aiohttp (#5019) add multipleOf to various codegen classes (#5021) Add a link to a youtube video on Pulp and OpenAPI Generator (#5038) [scripts] Remove misspelled OPENAPI_GENERATOR_DOWLOAD_CACHE_DIR (#5035) ...
cc @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01) @slash-arun (2019/11) @spacether (2019/11)
PR checklist
./bin/
(or Windows batch scripts under.\bin\windows
) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the code or mustache templates for a language ({LANG}
) (e.g. php, ruby, python, etc).master
,4.3.x
,5.0.x
. Default:master
.