Limit anyOf/oneOf discriminator to listed refs #145
Merged
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.
This addresses an issue where
resolve_ref
gets called for refs thataren't explicitly listed in
anyOf
oroneOf
. The specificationsays:
So for anyOf/oneOf discriminators, this uses the provided refs to build
a mapping of property values to schema objects for lookup during
validation. Explicit mappings are found by schema name or full ref to
support:
Impicit mappings are only created for refs under
#/components/schemas/
and are overridden by any explicit mappings that point to the same
schema.
allOf
discriminators still resolve refs because there isn't anexplicit list of allowed refs. Switched to
Schema#ref
now that itcalls
root.resolve_ref
itself.FIXED_FIELD_REGEX
comes from the spec:It's used in all cases to make sure schemas are only looked up by name
if the property value is a valid schema name.
Closes: #144