Skip to main content

discriminator-field-must-be-a-required-field

Overview

This rule belongs to the openapi-v3-standards-validation ruleset and states that:

The discriminator is the name of the property that decides which schema definition validates the structure of the model. This field must be marked as a required schema field.

PropertyValue
EnabledYes
Maximum SeverityError
MessageDiscriminator field is marked as optional.
CodeOPENAPI3STANDARDS_V337
TypeValidation
Rule SystemSemantic
Broad CategorySchemas
Products ImpactedAPI Transformer, Code Generation, Developer Experience Portal
Tagsopenapi3 openapi standards semantic validation discriminator property field schema

Suggested Fixes

  • Ensure that name of the schema property, which is marked as a discriminator, is also included in the schema's required list.
  • If the schema property should not be a required property, it should not be marked as a discriminator.
  • Name of the property marked as discriminator is compared with the schema property name in a case-sensitive manner.

For More Information