Swagger: “equivalent path already exists” despite

2019-01-20 11:16发布

问题:

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?

回答1:

That's because the two paths can be identical. I understand that the parameters may uniquely identify them, but Swagger 2.0 doesn't 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.