swagger-parser icon indicating copy to clipboard operation
swagger-parser copied to clipboard

Verify discriminator property

Open mgold opened this issue 9 years ago • 1 comments

Schema objects are allowed to have a discriminator property, which is described as

The discriminator is the schema property name that is used to differentiate between other schema that inherit this schema. The property name used 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.

The bolded sentence seems like something this parser should check. That is, these should fail (assume valid rest of swagger file):

# petType is not required
definitions:
  Pet:
    type: object
    discriminator: petType
    properties:
      name:
        type: string
      petType:
        type: string
    required:
    - name
# petType is not in properties
definitions:
  Pet:
    type: object
    discriminator: petType
    properties:
      name:
        type: string
    required:
    - name

mgold avatar Sep 20 '16 14:09 mgold

👍 Definitely on the to-do list

JamesMessinger avatar Oct 05 '16 13:10 JamesMessinger