-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to find discriminator targets #3591
Labels
Milestone
Comments
handrews
added
discriminator
clarification
requests to clarify, but not change, part of the spec
labels
Feb 18, 2024
I'm not aware of any comprehensive explanation. If the OpenAPI Description is a single document, then my assumption is that the entire schemas section of the Components Object should be searched for schemas that use |
This was referenced May 19, 2024
PRs merged! closing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
I just implemented a JSON-Schema validator and would like to add OpenAPI support to it.
I'm now stuck at adding discriminators with the "allOf" variant.
According to the spec a "discriminator MAY be added to a parent schema definition, and all schemas comprising the parent schema in an allOf construct may be used as an alternate schema."
However, I can't find the definition of "parent". The term "parent" in JSON Schema seems to mean something unrelated in JSON Schema, and I didn't see anything in the OpenAPI spec. I'm assuming it is the "parent" in the inheritance hierarchy, but that's not something that is well defined in JSON Schema (afaik).
Also: I can't just do this dynamically (waiting to encounter an discriminator), as I need to have the mappings targets statically. After, all, I might get the generic schema as "type" and then use the discriminator to validate the more specialized one.
There are a few cases that are obvious:
According to #2165 (comment) an
allOf
of anallOf
is also a valid target.What about a reference in an
if
?I'm guessing that one isn't valid, but my gut instinct would have said the same for the
allOf
of theallOf
.There are also some interesting cases:
If I have a schema in a different schema-resource (for example 'https://gigantic-server.com/schemas/Monster') that references my discriminator schema with "allOf", then clearly I can't find that schema. However, what if that same schema-resource is loaded through other means?
Does that schema then count as a target for the mapping?
Roughly:
It feels like finding all possible schemas that have the discriminator in it can become quite complicated.
Is there a description somewhere of how I can find all possible targets?
The text was updated successfully, but these errors were encountered: