Swagger-ui 锚链接到模型定义

2022-01-22 00:00:00 swagger swagger-ui javascript anchor

是否可以通过锚点直接访问通过 swagger-ui 的模型定义?

Is it possible to access a model definition of via swagger-ui directly via an anchor?

在示例页面 http://petstore.swagger.io/ 我看到锚适用于一组端点,例如http://petstore.swagger.io/#/pet.

In the example page http://petstore.swagger.io/ I see that the anchor works for a groups of endpoints, e.g. http://petstore.swagger.io/#/pet.

将鼠标悬停在模型描述上会显示一个锚点(例如 Category 模型的 #/definitions/Category),但是http://petstore.swagger.io/#/definitions/Category 不带我在那里.

Hovering the mouse over a model description shows me an anchor (e.g. #/definitions/Category for the Category model), but http://petstore.swagger.io/#/definitions/Category does not bring me there.

如果我检查元素,我会看到一个指向锚 pet 的真实链接:

If I inspect the elements, I see a real link to anchor pet:

<a class="nostyle" href="#/pet"><span>pet</span></a>

而对于 Category 这是一个 model-hint:

while for Category this is a model-hint:

<span class="model-hint">#/definitions/Category</span>

所以我想知道是否支持锚定模型..

So I wonder if anchoring models is supported at all..

推荐答案

Swagger UI 不支持模式/模型的永久链接.有一个现有的功能请求:
https://github.com/swagger-api/swagger-ui/issues/1369

Swagger UI does not support permalinks for schemas/models. There's an existing feature request:
https://github.com/swagger-api/swagger-ui/issues/1369

相关文章