Skip to main content

204-no-content-type

Disallows a Content-Type response header on status 204.

AttributeValue
CategoryOperations
MaturityGold
OpenAPISwagger 2.0; OpenAPI 3.0, 3.1, 3.2
StarterOff
Lenient–CompleteError

Intent

204 No Content has no response body, so declaring its media type is misleading.

Flags

A response whose status is exactly 204 and whose headers include Content-Type, matched case-insensitively.

Does not flag

Other status codes or 204 responses without that header. Body declarations are handled by response-body-not-allowed.

See it fail

responses:
'204':
description: Deleted
headers:
Content-Type:
schema:
type: string

Diagnostic: 204 responses should not define `Content-Type` header.

Fix it

responses:
'204':
description: Deleted

Configure

profiles:
default:
rules:
extends: [recommended]
override:
204-no-content-type: warn

Nearby: response-body-not-allowed, content-type-header-declared.