Schema discriminator property must match a property with the same name

Issue ID: v3-semantic-discriminator-value

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:

{
    "Pet": {
        "type": "object",
        "discriminator": {
            "propertyName": "animalType"
        },
        "properties": {
            "name": {
                "type": "string"
            },
            "petType": {
                "type": "string"
            }
        },
        "required": [
            "name",
            "animalType"
        ]
    }
}

Remediation

Make sure that all discriminator values match defined properties.

{
    "Pet": {
        "type": "object",
        "discriminator": {
            "propertyName": "petType"
        },
        "properties": {
            "name": {
                "type": "string"
            },
            "petType": {
                "type": "string"
            }
        },
        "required": [
            "name",
            "petType"
        ]
    }
}