Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger: "equivalent path already exists" despite different parameters

I'm trying to turn the Atom Publishing Protocol (RFC5023) in to a Swagger / OpenAPI spec to exercise writing those specs.

I ran into the following problem: in Atom there are different types of URIs, e.g. Collection and Member URIs. My idea was to document it like this:

paths:
  /{CollectionURI}:
    get:
      summary: List Collection Members
      ...
    post:
      summary: Create a Resource
      ...
    parameters:
      - $ref: "#/parameters/CollectionURI"
  /{MemberURI}:
    get:
      summary: Retrieve a Resource
      ...
    parameters:
      - $ref: "#/parameters/MemberURI"

When I do that, swagger-editor claims that

Equivalent path already exists: /{MemberURI}

Those are different types of URIs that return different things when queried. I want to call them differently to document them individually.

Is there any way to do this?

Thanks!

EDIT: The spec shows up just fine in Swagger-UI -- is this a bug in the editor or does the UI just ignore my error?

like image 493
trilean Avatar asked Feb 18 '16 10:02

trilean


1 Answers

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), 3.0 and 3.1 do not support full URI templates, and the path portion alone is inspected for uniqueness. So these:

/{foo}
/{bar}

are identical, even if foo must be a string, and bar must be a number. Please add your $0.02 on the OpenAPI Specification Repo as we're working on better path support right now.

like image 145
fehguy Avatar answered Oct 14 '22 15:10

fehguy