Skip to main content

no-inline-schemas-in-polymorphism

Overview

This rule belongs to the swagger-v2-standards-validation ruleset and states that:

Inline schema definitions, which do not have a given id, cannot be used in polymorphism. When using the discriminator, inline schemas will not be considered.

PropertyValue
EnabledYes
Maximum SeverityError
MessageInline schema is used in polymorphism.
CodeSWAGGER20STANDARDS_V317
TypeValidation
Rule SystemSemantic
Broad CategorySchemas
Products ImpactedAPI Transformer, Code Generation, Developer Experience Portal
Tagsswagger2 swagger standards semantic validation discriminator polymorphism schema inline definitions

Suggested Fixes

  • Remove the inline schema definition and relocate it to the definitions section.
  • Define the inline schema globally in the definitions section with a unique name. Then reference it using $ref in your current object with a path like '#/definitions/<global name>'.
  • The schema being discriminated i.e. the Schema Object containing the discriminator property should not be an inline schema.
  • When using allOf constructs with the discriminator, the schemas in these constructs must not be inline schemas.

For More Information