Created by: spacether
PR checklist
-
Read the contribution guidelines. -
Ran the shell script under ./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/python-petstore.sh
and./bin/security/python-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\
. -
Filed the PR against the correct branch: master
,. Default:3.4.x
,4.0.x
master
. -
Copied the technical committee to review the pull request if your PR is targeting a particular programming language.
Description of the PR
This PR lets python client users set model defaults on integers, numbers, and arrays when they are not currently able to in a swagger2.0 spec. The new code loads model variable examples into the model variable default value if the default is not already set and an example exists for the variable. Fixes this issue: https://github.com/OpenAPITools/openapi-generator/issues/1748
Reasons to do this: The current swagger-parser is not including default values that are float, integer, or array when processing a swagger2.0 spec. So in a swagger 2.0 spec, there is no way to set defaults on:
- integers
- numbers
- arrays
This PR adds in fallback code which uses and assigns a spec example value as the default value if one exists in the spec. So it uses examples to set defaults on the types
- string
- boolean
- integers
- numbers
- arrays
Tests
- test_type_holder_example.py added to verify that examples are loaded into defaults
- test_type_holder_default.py added to verify what default-only definition does and does not work
- samples updated to pass CircleCi tests (173 files)