Description
An empty schema {} accepts any value. When the API expects a particular structure, define its type and its fields or array elements.
Potential impact
A document-based check can pass even when a field the server needs is missing.
Remediation
For objects, specify properties and required. For arrays, describe the elements in items. Check a representative payload. If free-form data is intentional, document its purpose and enforce any necessary limits on the server.
Examples
The second GeneralError requires a string message. The integer code is optional, and extra fields are allowed.
Before
json
{
"components": {
"schemas": {
"GeneralError": {}
}
}
}
After
json
{
"components": {
"schemas": {
"GeneralError": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
},
"required": [
"message"
]
}
}
}
}