Swagger: “equivalent path already exists” despite different parameters

☆樱花仙子☆ 提交于 2019-12-17 20:46:18

问题


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.



来源:https://stackoverflow.com/questions/35478531/swagger-equivalent-path-already-exists-despite-different-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!