Description
HTTP responses to HEAD have no body. The same applies to 204 and 304 responses.
Potential impact
A client or test generated from a body schema may try to parse data the server cannot return.
Remediation
Remove the response’s content in OpenAPI 3.0 or its schema in 2.0. Keep the description and any applicable headers.
Examples
The revision removes the ApiVersion JSON body from 204 and describes the response as no content.
Before
json
{
"openapi": "3.0.0",
"paths": {
"/": {
"delete": {
"responses": {
"204": {
"description": "has content",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiVersion"
}
}
}
}
}
}
}
}
}
After
json
{
"openapi": "3.0.0",
"paths": {
"/": {
"delete": {
"responses": {
"204": {
"description": "no content"
}
}
}
}
}
}