redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

no-ambiguous-paths does not consider path parameter format

Open nicosp opened this issue 2 years ago • 1 comments

Describe the bug We have two paths /{id}/changes and /groups/{code}. Id is of type: string, format:uuid. When running lint we get a no-ambiguous-paths warning.

To Reproduce Steps to reproduce the behavior:

  1. Using default rules (or enable no-ambiguous-paths)
  2. And this OpenAPI file(s)
  3. Run lint
  4. You get a warning:
Paths should resolve unambiguously. Found two ambiguous paths: /{id}/changes and /groups/{code}.

29 |       '201':
30 |         description: 'Successful operation'
31 | '/groups/{code}':
32 |   get:
33 |     tags:

Warning was generated by the no-ambiguous-paths rule.

Expected behavior No warning since "groups" cannot match format uuid.

OpenAPI definition

openapi: 3.0.0
info:
  title: 'Test API'
  version: '1.0'
  description: "Simple spec that triggers no-ambiguous-paths"
  license:
    name: Test
    url: 'http://test.invalid/license'
servers:
  -
    url: 'http://localhost:8080/api'
paths:
  '/{id}/changes':
    get:
      tags:
        - Test
      summary: 'Test endpoint with uuid'
      operationId: getChanges
      parameters:
        -
          name: id
          in: path
          description: 'Id'
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '201':
          description: 'Successful operation'
  '/groups/{code}':
    get:
      tags:
        - Test
      summary: 'Get groups'
      operationId: getGroups
      parameters:
        -
          name: code
          in: path
          description: 'Code'
          required: true
          schema:
            type: string
      responses:
        '201':
          description: 'Successful operation'

Redocly Version(s) 1.0.0-beta.108

Node.js Version(s) v16.15.1

nicosp avatar Aug 24 '22 06:08 nicosp

Hi @nicosp,

Thanks for creating the issue.

tatomyr avatar Aug 25 '22 10:08 tatomyr

Hi, having the same with /projects/{project_id}/goals and /projects/tags/{id}. Both {project_id} and {id} are of type integer. Getting

Paths should resolve unambiguously. Found two ambiguous paths: `/projects/{project_id}/goals` and `/projects/tags/{id}`.

Checked also with Swagger Editor and Speccy, none of them produce this warning.

newstler avatar Apr 29 '23 18:04 newstler

Redocly is pretty opinionated, and may check for more or different "gotchas" than some of the other tools. Both these cases are ambiguous paths since they have overlapping segments, so I think that the tool is doing the expected thing when the rule is enabled. If your API has patterns like this but they aren't a problem (due to data types or something else that makes it obvious which path is which), then I'd recommend turning off the rule, or adding an exception for this instance of it.

Changing the rule behaviour to do different things for different parameter data types is likely to confuse more users than it helps - this rule is designed to catch unintentional path overlaps, but for APIs where it's not a problem, the rule can be turned off.

lornajane avatar May 02 '23 08:05 lornajane