# operation-success-response

Source: https://api-genie.dev/docs/linter/openapi/rules/operation-success-response

A rule of the OpenAPI linter, which reads OpenAPI 3.0, 3.1 and 3.2 documents. Since 0.0.1. In the rulesets: Recommended at error, Strict at error, All at error.

This rule checks that every operation declares at least one 2xx or 3xx response, as a status code
or as the `2XX` or `3XX` range.

## Rule details

The success response is the one clients are written for: its status, its body and its headers are
what a generated client returns and what a mock answers. An operation that declares only errors
leaves the main case to guesswork.

The rule reports `Operation must have at least one success response`.

## Examples

**Good**. A status code.

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

**Good**. A range.

```yaml
paths:
  /users:
    get:
      responses:
        2XX:
          description: A page of users.
```

**Bad**. Only an error.

```yaml
paths:
  /users:
    get:
      responses:
        "400":
          description: The query is invalid.
```
