unused-request-body
Since 0.0.1 · fixed by --fix · In the rulesets: Recommended at warning, Strict at error, All at error
This rule checks that GET, HEAD and TRACE operations have no request body.
Rule details
HTTP gives a body on these methods no meaning: proxies and caches may drop it, servers may reject the request, and most client libraries cannot send it. A document that declares one describes a request the API cannot receive, and generated clients either ignore the body or produce a call that fails.
The rule reports Unused request body on the operation.
Examples
Good.
paths:
/users:
get:
responses:
"200":
description: A list of users.
Bad. A GET with a body.
paths:
/users:
get:
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/User"
responses:
"200":
description: A list of users.
Automatic fixes
--fix removes requestBody from the GET, HEAD and TRACE operations.
Turn it off or change its severity
In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.rules has the details.
commands:
lint:
rules:
unused-request-body: off