Skip to main content

discriminator-mapping-values-for-all-involved-models

Overview

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

Discriminator mapping values indicate possible values that a discriminator property can have in a data and which concrete models they map to. This helps in the deserialization process. It is, therefore, expected that a mapping value is provided for each of the models involved in the type combinator definition and a missing value for any model would indicate incomplete information.

PropertyValue
EnabledYes
Maximum SeverityWarning
MessageDiscriminator mapping value information is missing for one or more models.
CodeAPIMATICPRE_V587
TypeValidation
Rule SystemSemantic
Broad CategoryGlobal Types/Models
Products ImpactedCode Generation, Developer Experience Portal, API Transformer
Tagspreliminary checks validation apimatic discriminator mapping values discriminator mapping discriminator complex model complex type model custom type global type combinators anyOf oneOf not

Suggested Fixes

  • Make sure that a discriminator mapping value is provided for all model/object types involved in the type combinator (anyOf, oneOf, not) definition.
  • Make sure that the model name in the discriminator mapping value matches exactly with the name of the model/object types involved in the type combinator (anyOf, oneOf, not) definition.
  • Names are compared in a case-sensitive manner.
  • Remove the models from the type combinator definition that have missing mapping information.