The value of the schema discriminator must be a required property

Description

The value of the discriminator property in the schema in question has not been listed as a required property.

The value of the discriminator property must be a string.

Example

The following is an example of how this issue could look in your API definition. Here, the discriminator petType is not included in the required properties:

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

Remediation

Make sure that all discriminator values are listed as required properties.

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

Get API Security news directly in your Inbox.

By clicking Subscribe you agree to our Data Policy