-
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
Are discriminators inherited with allOf? #2165
Comments
To answer your question directly, The If you have a request body specified as Looking at this scenario in isolation, strictly speaking, Lizard does not have to include Likewise, if the request body specified However, there are a few reasons why you might want
Also, there are a few problems with
There's some relevant discussion in #2141 that might also be useful. |
Thank you for that very thorough explanation. From it my understanding is that yes, all schemas that allOf contain a schema which includes a discriminator then also include that discriminator. That discriminator includes both propertyName and mapping. SpecD (mapping defined in discriminator):
Question about discriminator mappingFor specD Reptile, Lizard and Snake all contain the discriminator defined in Pet, yes? Which leads to my next question about additionalProperties. Question about AdditionalPropertiesSpecB (discriminator missing from Snake + Lizard)
So looking at SpecB above my interpretation is this: What would we do if the spec version was 3.0.1? Then additionalProperties is not True by default. In that case wouldn't deserializing into a final Snake instance fail because the property PetType is not part of the Snake schema? In that case would the returned instance be of type Reptile? |
I think the only remaining question here is about |
Are discriminator inheritable?
Given the following SpecA:
Do Reptile and Lizard contain the discriminator defined in Pet?
If discriminators are inheritable, then what is the correct interpretation of receiving payloads of type Reptile from the below specs?
SpecB (discriminator missing from Snake + Lizard)
SpecC: (discriminator present in Snake + Lizard)
The text was updated successfully, but these errors were encountered: