# paths-max-count

Source: https://apigenie.pl/docs/linter/swagger/rules/paths-max-count

A rule of the Swagger 2.0 linter, which reads Swagger 2.0 documents; OpenAPI 3 documents go to the OpenAPI linter. Since 0.9.0. In the rulesets: Recommended at warning, Strict at warning, All at error.

This rule checks whether a Swagger 2.0 document defines more paths than a
configured maximum.

## Rule details

A large number of paths may indicate that an API covers too many concerns and
could be split into smaller, more focused APIs.

The `paths-max-count` rule counts the entries of the root `paths` object and
reports `Too many paths found (<count>), maximum number is <maximum>` on the
document root when the count exceeds the configured maximum (8 by default).
Each path counts once, whatever the number of its operations.

The OpenAPI linter has a rule of the same name,
[paths-max-count](/docs/linter/openapi/rules/paths-max-count), for OpenAPI 3.x documents.

Turn the rule off for APIs that are large by design.

## Configuration

A single positive integer: the maximum number of paths. The default is 8.

```yaml
commands:
  lint:
    swagger:
      rules:
        paths-max-count: [warning, 20]
```

## Examples

**Good**. With a maximum of 2, the document defines 2 paths.

```yaml
swagger: '2.0'
info:
  title: Pet Store
  version: 1.0.0
paths:
  /pets:
    get:
      responses:
        '200':
          description: A list of pets.
  /owners:
    get:
      responses:
        '200':
          description: A list of owners.
```

**Bad**. With a maximum of 2, the document defines 3 paths.

```yaml
swagger: '2.0'
info:
  title: Pet Store
  version: 1.0.0
paths:
  /pets:
    get:
      responses:
        '200':
          description: A list of pets.
  /owners:
    get:
      responses:
        '200':
          description: A list of owners.
  /visits:
    get:
      responses:
        '200':
          description: A list of visits.
```
