# unused-request-body

Source: https://api-genie.dev/docs/linter/openapi/rules/unused-request-body

A rule of the OpenAPI linter, which reads OpenAPI 3.0, 3.1 and 3.2 documents. 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**.

```yaml
paths:
  /users:
    get:
      responses:
        "200":
          description: A list of users.
```

**Bad**. A `GET` with a body.

```yaml
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.
