FAQ

  • GitHub GitHub Repo stars
  • Discord Discord Server
  • ✨ New! Try the OpenAPI Doctor ✨ The OpenAPI Doctor
    Recommended

    oas2-discriminator


    Formats: Severity:

    The discriminator as part of the Schema Object adds support for polymorphism. It is the property used to differentiate between other schema that inherit from it.

    disciminator must be defined at this schema, and it must be in the required property list. When used, the value must be the name of this schema or any schema that inherits it.

    Why did this violation appear?

    A discriminator was used incorrectly, or it could be missing a required mapping.

    Bad Example

    swagger: 2.0
    paths:
      /melody:
        post:
          tags: 
            - little
            - song
    definitions:
      Song:
        discriminator: "love"
        type: object
        required: 
          - "cuddles"
    

    Good Example

    swagger: 2.0
    paths:
      /melody:
        post:
          tags:
            - little
            - song
    definitions:
      Song:
        discriminator: "love"
        type: object
        required:
          - "love"
    

    How do I fix this violation?

    Check discriminator values for correct use and that there is a matching required property.

    Spectral Equivalent

    The rule is equivalent to oas2-discriminator