Skip to content

Reasons why discriminator syntax only works with #[serde(untagged)] variables #1227

Answered by juhaku
nils-degroot asked this question in Q&A
Discussion options

You must be logged in to vote

The reason can be summarized to this #621, #617 and #346. And it relates to this issue OpenAPITools/openapi-generator#1086. In short the discriminator should only be used with $ref fields and not with schema combining $ref and inlined objects according to 3.1.0 version of spec https://spec.openapis.org/oas/v3.1.0.html#discriminator-object.

When using the discriminator, inline schemas will not be considered.

However as I see this mention has been removed from the latest spec 3.1.1 version so there might be some changes towards supporting this functionality officially. I am not tracking changes what's coming into the OpenAPI in general.

Perhaps it would be good to use some tool to lint th…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nils-degroot
Comment options

Answer selected by nils-degroot
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