question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Equivalent paths are not allowed even thogh the path + verb combination is different

See original GitHub issue

Paste this spec in https://editor.swagger.io:

info:
  title: Server
  version: 1.0.0

host: 'localhost:8000'
basePath: /
produces:
  - application/json

schemes:
  - http

swagger: '2.0'
paths:
  
  '/path/{paramName}':
    get:
      summary: Get paramName
      parameters:
        - name: paramName
          in: path
          required: true
          type: string
      responses:
        '200':
          description: Success
  '/path/{someOtherParamNameButTheVerbIsPut}':
    put:
      summary: Update paramName
      parameters:
        - name: someOtherParamNameButTheVerbIsPut
          in: path
          required: true
          type: string
      responses:
        '200':
          description: Success

Though path+verb combinations are different, it throws error. This is not expected at all!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

19reactions
nickdnkcommented, Dec 10, 2018

I have this problem as well. Consider this:

I want to add multiple entries all under a specific date:

POST /something/{date}

Each entry gets and ID, which means I can delete or update individual entries like this:

DELETE /something/{id} PATCH /something/{id}

{id} needs to be validated as an integer, {date} as a date string, and I cannot just put them under the same path, because then the variable needs to be named something like {dateOrId}, which is super ugly and misleading (but works!).

Given that the methods don’t overlap because of different verbs, there’s no way this can ever cause a conflict, and it works fine in the real world as well.

Please reconsider this limitation in the future.

12reactions
hkosovacommented, Oct 7, 2019

TL;DR: This is a limitation of the OpenAPI Specification and not a Swagger Editor issue.


The error means that these paths
/path/{paramName}
/path/{someOtherParamNameButTheVerbIsPut}

are considered identical and therefore invalid. They are identical because there’s no way to tell if /path/foo corresponds to /path/{paramName} or /path/{someOtherParamName}. The parameter name alone does not make the path unique.

What you can do is define a single path /path/{paramName} with 2 operations get and put:

paths:
  /path/{paramName}:
    get:
      ...
    put:
      ...

This limitation has been previously discussed in the OpenAPI Specification repository here: https://github.com/OAI/OpenAPI-Specification/issues/576 https://github.com/OAI/OpenAPI-Specification/issues/788


If you want to change the path matching behavior, file an enhancement request with OpenAPI Specification:
https://github.com/OAI/OpenAPI-Specification/issues

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger: "equivalent path already exists" despite different ...
That's because the two paths can be identical. I understand that the parameters may uniquely identify them, but OpenAPI 2.0 (Swagger 2.0), ...
Read more >
Paths and Operations - Swagger
OpenAPI defines a unique operation as a combination of a path and an HTTP method. This means that two GET or two POST...
Read more >
Fix your Swagger Definition! - NotAllAboutCode
Equivalent paths are not allowed.", "Schema error at paths ... should NOT have additional properties", "Schema error at paths ... should be ...
Read more >
The Grammar According to West - Math
The mathematics will be easier to read when the formulas are separated by the comma plus words that enable the reader to understand...
Read more >
systemd.unit - Freedesktop.org
When the unit is enabled, symlinks will be created for those names, ... was a path (the unescaping results are different for paths...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found