Schema discriminator property must be a string

Issue ID: v3-semantic-discriminator-string

Description

You have defined a discriminator that is not a string. Discriminators must always be of the type string.

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 type of the discriminator age is integer:

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

Remediation

Make sure that all discriminator values are strings.

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