Merged
requested to merge github/fork/spacether/produces_freeform_objects_with_validation into master
Created by: spacether
If a free form object schema has validations I think that we should generate it as a model
- I think that we should do this to allow another composed schema to oneOf include an object schema with validations
- In the current master branch, those validations are omitted because there will not be a model to contain the validations
If a free form schema is used as an interface schema (another schema allOf includes it) I think that we should generate the interface as a model
- Note: this is another way of implementing interface models which is similar to https://github.com/OpenAPITools/openapi-generator/pull/6849 but doesn't require our users to know about a specific vendor extension.
If merged, this will resolve https://github.com/OpenAPITools/openapi-generator/issues/7361 for python-experimental only
- Tests added for these free form schema use cases
How this change was made:
- unaliasSchema is changed into a public method in each generator
- when generating models, if we are examining a FreeFormObject, we create a schema ref to it and see if unaliasSchema preserves the ref(meaning the model will be generated) or it unaliases the schema (meaning the model won't be generated)
- the method hasValidation is added to codegenModel to return a boolean saying if there is validation in the root level of the component schema that we are examining. This is needed to check if arrayModels have validations in all generators that make arraymodels. This is also needed in python-experimental to produce FreeFormObject models with validation.
PR checklist
-
Read the contribution guidelines. -
Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community. -
If contributing template-only or documentation-only changes which will change sample output, build the project beforehand. -
Run the shell script ./bin/generate-samples.sh
to update all Petstore samples related to your fix. 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*
. For Windows users, please run the script in Git BASH. -
File the PR against the correct branch: master
-
Copy the technical committee to review the pull request if your PR is targeting a particular programming language.
Python Technical Committee @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01) @arun-nalla (2019/11) @spacether (2019/11)