path-parameters-defined

path-parameters-defined

This rule ensures that for all parameter placeholders defined in path item URLs, there are path parameters defined in corresponding path items or their operations.

Rule Details

The path-parameters-defined rule is designed to ensure that for all parameter placeholders defined in path item URLs, there are corresponding path parameters defined in the path items or their operations. This helps to maintain consistency and clarity in the API’s structure.

Configuration

None.

Examples

Good.

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

Bad. Definition of the userId parameter is missing.

paths:
  /users/{userId}:
    get:
      summary: Get a user by ID

When Not to Use It

If your API does not use path parameters or if you have other means of ensuring that all parameter placeholders have corresponding path parameters, you may not need to use this rule.

Compatibility

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

← Back to Index