OpenAPI discriminator does not resolve missing or unknown subtype values
0 reputation · 19 Sept 2025, 03:35 UTC
OpenAPI discriminator does not resolve missing or unknown subtype values
A schema uses the discriminator keyword with propertyName and mapping to select among child schemas in components/schemas. The goal is to determine what happens when a payload omits the discriminator property or sends a value that matches no mapping key: resolve to a default subtype, reject the payload, or fall back to the parent schema.
The OpenAPI Specification leaves missing, unknown, or ambiguous discriminator values to implementations, so validators and generators disagree. Mapping keys are case-sensitive and generally must match schema names exactly. Behavior also varies between OpenAPI 3.0.x and 3.1.x toolchains, and composition with oneOf, anyOf, or allOf is not uniformly specified.
Should an absent or unmatched discriminator value produce a validation error, a fallback subtype, or an unresolved type, and does that depend on the OpenAPI version?