Description
required lists the properties an object must contain. Their types may be defined in properties or in a referenced or composed schema.
Potential impact
An unspecified type leaves callers guessing what value to send. If the schema also forbids that property, no object can satisfy both rules.
Remediation
Check all applicable definitions and additionalProperties. Keep each mandatory name in required and specify the type and description wherever they are missing.
Examples
These OpenAPI 3.0 excerpts omit info and paths.
Before
json
{
"openapi": "3.0.0",
"components": {
"schemas": {
"GeneralError": {
"type": "object",
"properties": {
"code": {
"type": "integer"
}
},
"required": [
"code",
"message"
]
}
}
}
}
After
json
{
"openapi": "3.0.0",
"components": {
"schemas": {
"GeneralError": {
"type": "object",
"properties": {
"code": {
"type": "integer"
},
"message": {
"type": "string"
}
},
"required": [
"code",
"message"
]
}
}
}
}
Both schemas require code and message. The first allows additional properties and leaves message untyped. The second defines it as a string.