Skip to main content

valid-discriminator-field

Overview

This rule belongs to the apimatic-preliminary-validation ruleset and states that:

If a discriminator is set for the model, a corresponding discriminator field should be part of the model fields. This discriminator field should be optional and of "String" type only. The name of the discriminator field must match with the name of the discriminator set in the model.

PropertyValue
EnabledYes
Maximum SeverityError
MessageThe discriminator field defined in the model is invalid.
CodeAPIMATICPRE_V504
TypeValidation
Rule SystemSemantic
Broad CategoryGlobal Types/Models
Products ImpactedCode Generation, Developer Experience Portal, API Transformer
Tagspreliminary checks validation apimatic discriminator inheritance type custom type model complex model

Suggested Fixes

  • Make sure there is only one field named equal to the discriminator in the model and that it is optional. Remove all other conflicting fields.
  • Make sure the discriminator field is string-typed. Other types (including enumerations) are not supported.

For More Information