[Python] Add enum support when building default values for model properties when using $ref#18796
Conversation
$ref
|
@wing328 @spacether @krjakbrjak I don't see Flask/Connexion as being supported (just FastAPI) but this impacts all of Python. |
$ref$ref
| } | ||
| if (enumName != null) { | ||
| var.defaultValue = toEnumDefaultValue(enumName, var.datatypeWithEnum); | ||
| var.defaultValue = toEnumDefaultValue(var, enumName); |
There was a problem hiding this comment.
fyi @OpenAPITools/generator-core-team
| outputDir: samples/server/petstore/python-flask | ||
| outputDir: samples/server/petstore/2_0/python-flask | ||
| inputSpec: modules/openapi-generator/src/test/resources/2_0/python-flask/petstore.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/python-flask |
There was a problem hiding this comment.
we don't test 2.0 spec so no need to keep this sample folder and yaml config file
|
Something went wrong doing the rebase - will fix |
|
The code is now correct, but the commit history is a bit mangled. I can open another PR if that's a problem. Let me know! @wing328 |
23300fb to
1d8dd73
Compare
|
thanks for the PR. the commit history looks ok as we will squash the commits during merge. tested python client with the new test schemas and the result is good: #18882 |
|
fyi. filed #18883 to add the tests in python client as well |
|
@welshm when you've time, can you please PM me via Slack? thanks. |
Add in better processing for enums in Python when they are a $ref
DefaultCodegen.javawithpublic String toEnumDefaultValue(CodegenProperty property, String value)PR checklist
Commit all changed files.
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*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming 7.6.0 minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)