no-content-response-defined

Since 0.0.1 · fixed by --fix · In the rulesets: Recommended at error, Strict at error, All at error

This rule checks that no 204 response declares content.

Rule details

A 204 response has no body, by the HTTP specification. A document that gives one a schema promises clients something the server never sends, and generated clients wait for a body that does not come.

The rule reports 204 response may not have a body defined.

Examples

Good. The response says only what happened.

paths:
  /users/{id}:
    delete:
      responses:
        "204":
          description: User deleted.

Bad. A body on a 204 response.

paths:
  /users/{id}:
    delete:
      responses:
        "204":
          description: User deleted.
          content:
            application/json:
              schema:
                type: object

Automatic fixes

--fix removes content from the 204 responses the rule reports.

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:
      no-content-response-defined: off
Was this helpful?