# path-parameters-on-items

Source: https://apigenie.pl/docs/linter/openapi/rules/path-parameters-on-items

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 warning, Strict at warning, All at error.

This rule checks that path parameters are declared on the path item, not repeated on each of its
operations.

## Rule details

A placeholder belongs to the path, so its parameter belongs to the path item: declared once, it
applies to every operation, and a change to its type or description happens in one place.
Declared on the operations, the copies drift apart.

The rule reports `One or more path parameters are missing or not defined in path item`.

## Examples

**Good**. One declaration for every operation of the path.

```yaml
paths:
  /users/{userId}:
    parameters:
      - name: userId
        in: path
        required: true
        schema:
          type: string
    get:
      summary: Get a user by ID
    delete:
      summary: Delete a user by ID
```

**Bad**. The same parameter, once per operation.

```yaml
paths:
  /users/{userId}:
    get:
      summary: Get a user by ID
      parameters:
        - name: userId
          in: path
          required: true
          schema:
            type: string
    delete:
      summary: Delete a user by ID
      parameters:
        - name: userId
          in: path
          required: true
          schema:
            type: string
```
