Skip to main content

all-model-types-in-type-combinator-with-discriminator

Overview

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

A discriminator property in a global type combinator definition helps simplify deserialization of model types. This means that the types involved must be complex objects. If only primitive types are expected, a discriminator property is not applicable.

PropertyValue
EnabledYes
Maximum SeverityError
MessageDiscriminator property is not applicable in the current context.
CodeAPIMATICPRE_V588
TypeValidation
Rule SystemSemantic
Broad CategoryGlobal Types/Models
Products ImpactedCode Generation, Developer Experience Portal, API Transformer
Tagspreliminary checks validation apimatic discriminator global type combinators type combinator type cases anyOf oneOf not models types custom types complex models

Suggested Fixes

  • Use a discriminator only when complex objects are involved in the type combinator (anyOf, oneOf, not) cases.
  • Remove any primitive type entry from the type combinator (anyOf, oneOf, not) cases.
  • Remove discriminator information if complex objects are not expected.