Category: Status Codes & Responses
Description
Operations that accept request bodies should define a 415 Unsupported Media Type response to indicate when the client sends content in an unsupported format.
What It Checks
This rule checks POST, PUT, and PATCH operations that have a request body defined and verifies they include a 415 response definition.
- Only checks operations that can have request bodies (POST, PUT, PATCH)
- Verifies the operation has a requestBody defined
- Checks for explicit 415 response definition
Why It Matters
Documenting the 415 response is important for:
- Content Type Clarity: Developers know what content types are accepted
- Error Handling: Clients can handle format mismatches appropriately
- Debugging: Clear feedback when wrong content type is sent
- API Contract: Documents the expected input formats
Examples
Good
paths:
/users:
post:
operationId: createUser
requestBody:
content:
application/json:
schema:
type: object
responses:
'201':
description: User created
'415':
description: Unsupported Media Type - Use application/json
Bad
paths:
/users:
post:
operationId: createUser
requestBody:
content:
application/json:
schema:
type: object
responses:
'201':
description: User created
# Missing 415 response
Exceptions
- GET, DELETE, and other operations that don't accept request bodies
- Operations without a requestBody definition
Configuration
This rule has no configuration options. It is either enabled or disabled.
Related Rules
- Rule 39: Content-Type Must Be Used - Content type requirements
- Rule 57: Common Status Codes - Common error responses