# parameters-unique

Source: https://apigenie.pl/docs/linter/openapi/rules/parameters-unique

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

This rule checks that no path item or operation declares two parameters with the same name and
location.

## Rule details

A name and a location identify a parameter: two declarations of `id` in the path are one parameter
with two definitions, and each tool picks one of them. The same name in two locations, `id` in
the path and `id` in the query, is two parameters and is allowed.

The rule reports `Duplicate parameter name '...' in location '...'` on the later declaration.

## Examples

**Good**. Two parameters, two names.

```yaml
paths:
  /users/{id}:
    get:
      parameters:
        - name: id
          in: path
          description: The ID of the user to retrieve.
          required: true
          schema:
            type: string
        - name: with-relations
          in: query
          description: If true, also returns related resources.
          required: false
          schema:
            type: boolean
```

**Good**. The same name in two locations.

```yaml
paths:
  /users/{id}:
    get:
      parameters:
        - name: id
          in: path
          description: The ID of the user to retrieve.
          required: true
          schema:
            type: string
        - name: id
          in: query
          description: Confusing, but allowed.
          required: false
          schema:
            type: boolean
```

**Bad**. `id` in the path twice, with two types.

```yaml
paths:
  /users/{id}:
    get:
      parameters:
        - name: id
          in: path
          description: The ID of the user to retrieve.
          required: true
          schema:
            type: string
        - name: id
          in: path
          description: The ID of the user to retrieve.
          required: true
          schema:
            type: boolean
```

## Automatic fixes

`--fix` removes a later duplicate when its definition is identical to the first one. Duplicates
that differ stay for you to merge.
