Skip to content
rest/http/status-method-contradiction

Status code incompatible with method

Response statuses agree with operation method semantics.

error

Examples

FlaggedFails
{
"documents": {
"openapi.json": {
"info": {
"title": "Fixture",
"version": "1"
},
"openapi": "3.1.2",
"paths": {
"/widgets": {
"post": {
"responses": {
"304": {
"description": "cached"
}
}
}
}
}
}
},
"entrypoint": "openapi.json"
}
PassesClean
{
"documents": {
"openapi.json": {
"info": {
"title": "Fixture",
"version": "1"
},
"openapi": "3.1.2",
"paths": {
"/widgets": {
"get": {
"responses": {
"304": {
"description": "cached"
}
}
}
}
}
}
},
"entrypoint": "openapi.json"
}

Why it matters

The contract promises a response status whose semantics cannot apply to that method.

How detection works

A non-GET operation declares 206, or an operation other than GET or HEAD declares 304.

What is inspected

  • an explicit three-digit response status and parsed HTTP method

Limits

  • recommending success statuses
  • inferring behavior from operation names
  • Only explicit 206 and 304 method relationships are checked.
  • GET with 206 and GET or HEAD with 304 remain clean.
  • Response ranges and default responses are not inferred.

How to fix it

Use a status compatible with the operation method.

  1. Remove the status or move it to an operation whose method supports it.

Verify

  • Run repo-lint rest check again against the same tracked contract and semantics.