Skip to content

3.1.1: polymorphism and discriminator in request type #4404

Answered by handrews
hfhbd asked this question in Q&A
Discussion options

You must be logged in to vote

@hfhbd The allOf syntax for discriminator is weird for the reason you mention. Among others. We keep trying to explain it better, but AFAIK none of the people who came up with it are still active with the project, so it's a bit of archaeology and we keep finding new surprises.

What's going on here is that for validation purposes, the allOf approach only works if you are validating using a child schema, which means you already have to know what child it will be. This is because discriminator is not allowed to change the validation outcome, because doing so in the allOf case would outright contradict the JSON Schema specification, for reasons that are too complex to go into here. JSON Schem…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@hfhbd
Comment options

@handrews
Comment options

Answer selected by hfhbd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants