Skip to content

As per OAS, when defining discriminator with explicit mapping, should implicit discriminator value still be accepted? #3918

Answered by handrews
ondrej-simon asked this question in Q&A
Discussion options

You must be logged in to vote

@ondrej-simon I think you're making this more complicated than it is. The algorithm is very simple:

  • If there is an explicit mapping for the exact, case-sensitive value, then use the explicit mapping
  • Otherwise, if there is an implicit mapping for the exact, case-sensitive value, then use the implicit mapping
  • If neither exists, fail

There are no other checks involved. There's nothing that "masks" based on differences in case. There's nothing preventing multiple values from mapping (implicitly or explicitly) to the same schema. It's just those two steps, nothing else.

I've adjusted your scenarios accordingly:

Scenario 1 - no mapping specified

This scenario is correct as you wrote it (altho…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
6 replies
@handrews
Comment options

@ondrej-simon
Comment options

@handrews
Comment options

@handrews
Comment options

@ondrej-simon
Comment options

Comment options

You must be logged in to vote
1 reply
@ondrej-simon
Comment options

Answer selected by ondrej-simon
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