fix(python): support default values for array/map field#21707
fix(python): support default values for array/map field#21707CatBraaain wants to merge 1 commit intoOpenAPITools:masterfrom
Conversation
|
thanks for the pr can you please add some tests schemas to |
732ba2b to
b47c2b8
Compare
|
@wing328 |
b47c2b8 to
e95377a
Compare
|
can you please review CI build errors when you've time? let us know if you need any help |
e95377a to
09d8d0c
Compare
|
@wing328 |
|
triggered the workflow again but some tests still failed please take a look when you've time have a nice weekend |
|
This PR was created to support default values for array and map types on the Python client side. However, after further investigation, I recognized that embedding default values on the client side is incorrect for the following reasons. According to the OpenAPI specification, the Additionally, the OpenAPI Generator TypeScript client does not set default values for model properties, leaving unset properties as For these reasons, I close this PR. |
What done
Setting mutable objects as default values is safe in Pydantic v2.
Therefore, this change updates the generator to support default values for array and map types
by treating them similarly to primitive types.
Rationale
Reference: https://docs.pydantic.dev/latest/concepts/fields/#mutable-default-values
@cbornet (2017/09) @tomplus (2018/10) @krjakbrjak (2023/02) @fa0311 (2023/10) @multani (2023/10)
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(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)