Schema discriminator property must be a string

Issue ID: 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:

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

Remediation

Make sure that all discriminator values are strings.

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