Description
A discriminator tells clients which subtype a value represents. OpenAPI 3.0 names the field in discriminator.propertyName. Swagger 2.0 puts its name directly in discriminator.
Potential impact
If the field or its values are ambiguous, clients and servers may select different subtypes.
Remediation
Locate the field in the payload and the applicable schemas, including references and composed schemas. Require it and check which subtype each supported value selects.
Examples
These OpenAPI 3.0 excerpts show the parent schema only. They omit info, paths, and the subtype definitions and composition.
Before
{
"openapi": "3.0.0",
"components": {
"schemas": {
"GeneralError": {
"type": "object",
"discriminator": {
"propertyName": "petType"
},
"properties": {
"code": {
"type": "integer"
},
"message": {
"type": "string"
}
},
"required": [
"petType"
]
}
}
}
}
After
{
"openapi": "3.0.0",
"components": {
"schemas": {
"GeneralError": {
"type": "object",
"discriminator": {
"propertyName": "petType"
},
"properties": {
"code": {
"type": "integer"
},
"message": {
"type": "string"
},
"petType": {
"type": "string"
}
},
"required": [
"petType"
]
}
}
}
}
Both versions require petType. The revision gives it a string type. Check its values against the subtypes your API supports.