operation-id-unique

operation-id-unique

This rule checks whether operations defined in an OpenAPI schema have unique IDs.

Rule Details

Duplicate operation ID make it difficult to reason about their purpose, as well as about.

The operation-id-unique rule checks IDs of operations defined in an OpenAPI schema and warn if duplicates found. Empty operation IDs do not count as duplicates.

Configuration

None.

Examples

Good. It is immediately visible what each operation does.

paths:
  /users:
    get:
      operationId: getUsers
      responses:
        "200":
          description: A list of users.
  /users/{id}:
    get:
      operationId: getUserById
      responses:
        "200":
          description: A single user.

Bad. Two operations have identical IDs, which makes it difficult to decide which one to use in each case.

paths:
    /downloads:
        patch:
            # changes the status to 'cancelled'
            operationId: cancelDownload
            ...
        delete:
            operationId: cancelDownload
            ...

When Not to Use It

We recommend to always enable this rule.

Compatibility

This rule is compatible with all OpenAPI 3.x versions.

← Back to Index