-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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] Add enum support when building default values for model properties when using $ref
#18796
[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
@@ -6750,7 +6762,7 @@ public void updateCodegenPropertyEnum(CodegenProperty var) { | |||
} | |||
} | |||
if (enumName != null) { | |||
var.defaultValue = toEnumDefaultValue(enumName, var.datatypeWithEnum); | |||
var.defaultValue = toEnumDefaultValue(var, enumName); |
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.
fyi @OpenAPITools/generator-core-team
@@ -1,4 +1,4 @@ | |||
generatorName: python-flask | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't test 2.0 spec so no need to keep this sample folder and yaml config file
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.
Updated - thanks!
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.java
withpublic 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)