Swagger:“等效路径已经存在"尽管参数不同 [英] Swagger: "equivalent path already exists" despite different parameters

查看:34
本文介绍了Swagger:“等效路径已经存在"尽管参数不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Atom 发布协议 (RFC5023) 转换为 Swagger/OpenAPI 规范以练习编写这些规范.

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

我遇到了以下问题:在 Atom 中有不同类型的 URI,例如集合和成员 URI.我的想法是像这样记录它:

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"

当我这样做时,swagger-editor 声称

When I do that, swagger-editor claims that

等效路径已存在:/{MemberURI}

Equivalent path already exists: /{MemberURI}

这些是不同类型的 URI,在查询时返回不同的内容.我想以不同的方式称呼它们以单独记录它们.

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?

谢谢!

该规范在 Swagger-UI 中显示得很好——这是编辑器中的错误还是 UI 只是忽略了我的错误?

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

推荐答案

那是因为两条路径可以相同.我知道参数可以唯一地标识它们,但 Swagger 2.0 不支持完整的 URI 模板,并且仅检查路径部分的唯一性.所以这些:

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}

是相同的,即使 foo 必须是字符串,而 bar 必须是数字.请在 OpenAPI 规范存储库上添加您的 0.02 美元,因为我们正在努力提供更好的路径支持现在.

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.

这篇关于Swagger:“等效路径已经存在"尽管参数不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆