swagger-parser
swagger-parser copied to clipboard
Verify discriminator property
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
requiredproperty 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
👍 Definitely on the to-do list