Description
In OpenAPI 2.0 and 3.0, each operation needs at least one entry in responses. Reusable definitions in components.responses or the Swagger 2.0 top-level responses are optional.
Potential impact
With no response definition, callers and SDK generators lack the status and data format to expect.
Remediation
Under the operation, describe the normal result and known errors. Include any returned content. Use default for codes without an explicit definition.
Examples
These OpenAPI 3.0 excerpts omit info.
Before
json
{
"openapi": "3.0.0",
"paths": {
"/": {
"get": {
"responses": {}
}
}
}
}
After
json
{
"openapi": "3.0.0",
"paths": {
"/": {
"get": {
"responses": {
"200": {
"description": "OK"
}
}
}
}
}
}
The second GET defines 200. Use it only if the server returns it.