Schema discriminator property must match a property with the same name

Description

The discriminator of the schema in question must match a property with the same name.

For more details, see the OpenAPI Specification.

Example

The following is an example of how this issue could look in your API definition. Here, the discriminator value is animalType but the defined property is actually called petType:

1definitions:
2  Pet:
3    type: object
4    discriminator: animalType
5    properties:
6      name:
7        type: string
8      petType:
9        type: string
10    required:
11      - name
12      - animalType
13

Remediation

Make sure that all discriminator values match defined properties.

1definitions:
2  Pet:
3    type: object
4    discriminator: petType
5    properties:
6      name:
7        type: string
8      petType:
9        type: string
10    required:
11      - name
12      - petType
13

Copyright 42Crunch 2021