Skip to main content

spec-discriminator-defaultMapping

Requires a discriminator's defaultMapping to identify an existing schema component.

AttributeValue
CategorySchema
MaturityPlatinum
OpenAPIOpenAPI 3.2
Starter–LenientOff
Recommended–StrictWarning
CompleteError

Intent

defaultMapping provides the fallback schema when no explicit discriminator mapping matches. A missing target makes that fallback unusable.

Flags

An OpenAPI 3.2 discriminator whose defaultMapping value matches neither a full component name nor the final schema name in the reference-like value.

Does not flag

Existing component targets, discriminators without defaultMapping, or documents earlier than OpenAPI 3.2.

See it fail

components:
schemas:
Animal:
discriminator:
propertyName: kind
defaultMapping: '#/components/schemas/UnknownAnimal'

UnknownAnimal is not defined under components.schemas.

Fix it

Point to an existing component:

components:
schemas:
Animal:
discriminator:
propertyName: kind
defaultMapping: '#/components/schemas/GenericAnimal'
GenericAnimal:
type: object

Configure

Rule IDs are case-sensitive; preserve the capital M in defaultMapping.

profiles:
default:
rules:
extends: [recommended]
override:
spec-discriminator-defaultMapping: error

Nearby: duplicate-oneof-discriminator.