-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[python-experimental] Allow schema instances to be passed in and pass additional schema validations #12758
Merged
spacether
merged 28 commits into
OpenAPITools:master
from
spacether:feat_fixes_issue_12736
Jul 9, 2022
Merged
[python-experimental] Allow schema instances to be passed in and pass additional schema validations #12758
spacether
merged 28 commits into
OpenAPITools:master
from
spacether:feat_fixes_issue_12736
Jul 9, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
605458c
to
a4afdd3
Compare
…_types, fixes test test_deserialize_oneof_reference
…tpye checking and unique items checking simpler
a4afdd3
to
9ffefb9
Compare
Waiting for this change to be released. I confirm that I had an error with optional booleans in 6.0.1, and it appears to be fixed when building The error was:
|
6 tasks
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow schema instances to be passed in and pass additional schema validations
In polymorphic use cases, an instance may be passed in which is of type Dog but in the schema that we are deserializing, the field is of type Animal. As long as the dog payload can validate as an Animal also, that should be permitted.
This PR updates cast_to_allowed_values so that when a schema instance is ingested, the instance is converted back to a primitive payload (Decimal/str/NoneClass/BoolClass, NOT a Schema instance). With that primitive payload, all validations can be run, and the new DynamicSchema class can be manufactured containing all passed validations and the payload can be instantiated as that new class. So in the output, the Dog instance will now be of type Dog AND Animal.
When Schema instances are ingested, the code should not have to re-run validation on already validated Schema classes for a given payload. So that information is persisted in ValidationMetadata and validating a schema class is skipped if it was validated earlier.
PR checklist
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.
master
(6.0.1) (patch release),6.1.x
(breaking changes with fallbacks),7.0.x
(breaking changes without fallbacks)