Ambiguous path definitions

Do not treat identical path patterns with different variable names as separate endpoints.

Description

OpenAPI treats /users/{id} and /users/{ids} as the same path. Changing a parameter name does not create another endpoint.

Potential impact

Duplicate paths can make SDKs and tests select the wrong operation.

Remediation

Group methods for the same resource under one path. Give distinct resources distinct paths and match them in the server and clients. Declare every placeholder as a required path parameter.

Examples

Use /user-groups/{id} only if that route exists. The excerpts omit info and the parameter declarations.

Before

yaml
openapi: 3.0.0
paths:
  "/users/{id}":
    get:
      responses:
        "200":
          description: OK
  "/users/{ids}":
    get:
      responses:
        "200":
          description: OK

After

yaml
openapi: 3.0.0
paths:
  "/users/{id}":
    get:
      responses:
        "200":
          description: OK
  "/user-groups/{id}":
    get:
      responses:
        "200":
          description: OK

References