content-type-header-overrides-media-type
Finds a fixed Content-Type header value that disagrees with a request or response content key.
| Attribute | Value |
|---|---|
| Category | Operations |
| Maturity | Platinum |
| OpenAPI | Swagger 2.0; OpenAPI 3.0, 3.1, 3.2 |
| Starter | Off |
| Lenient–Strict | Warning |
| Complete | Error |
Intent
Two conflicting media-type declarations leave Specmatic and other tools needing to choose which one wins.
Flags
- A request
Content-Typeheader parameter with one known value that differs from a request-body content key. - A response
Content-Typeheader with one known value that differs from a response content key.
The known value may come from a one-value enum, const, default, or example. Media-type comparison is exact.
Does not flag
Matching values, headers without a stable single value, or operations without corresponding content.
See it fail
parameters:
- name: Content-Type
in: header
schema:
type: string
enum: [application/xml]
requestBody:
content:
application/json:
schema:
type: object
The header says XML while the content map says JSON.
Fix it
Prefer one source of truth and remove the header declaration:
requestBody:
content:
application/json:
schema:
type: object
Configure
profiles:
default:
rules:
extends: [recommended]
override:
content-type-header-overrides-media-type: error
Nearby: content-type-header-declared, accept-response-content-type-conflict.