gpt4 book ai didi

swagger - 如何在 Swagger UI 中使用 OpenAPI 3.0 响应 "links"?

转载 作者:行者123 更新时间:2023-12-01 17:35:48 27 4
gpt4 key购买 nike

我正在编写 Open API 3.0 规范并尝试获取 response links在 Swagger UI v 3.18.3 中渲染。

示例:

openapi: 3.0.0
info:
title: Test
version: '1.0'
tags:
- name: Artifacts
paths:
/artifacts:
post:
tags:
- Artifacts
operationId: createArtifact
requestBody:
content:
application/octet-stream:
schema:
type: string
format: binary
responses:
201:
description: create
headers:
Location:
schema:
type: string
format: uri
example: /artifacts/100
content:
application/json:
schema:
type: object
properties:
artifactId:
type: integer
format: int64
links:
Read Artifact:
operationId: getArtifact
parameters:
artifact-id: '$response.body#/artifactId'
/artifacts/{artifact-id}:
parameters:
- name: artifact-id
in: path
required: true
schema:
type: integer
format: int64
get:
tags:
- Artifacts
operationId: getArtifact
responses:
200:
description: read
content:
application/octet-stream:
schema:
type: string
format: binary

呈现如下链接:

Response Link Example

这是预期的吗?我问这个问题是因为 operationId 暴露在 UI 上,并且 parameters 显示为 JSON 引用,这使得某些内容看起来无法正确显示。我本希望有一个超链接或其他内容将我带到 Swagger 网页中与该链接引用的 API 相对应的相应部分。

最佳答案

是的,这就是 Swagger UI 目前呈现 OAS3 链接的方式。 链接 的渲染是 their OAS3 support backlog 上的内容之一:

OAS 3.0 Support Backlog
This is a collection ticket for OAS3 specification features that are not yet supported by Swagger-UI.
...
[  ] Links can't be used to stage another operation
[  ] Link-level servers are not available for executing requests

关于swagger - 如何在 Swagger UI 中使用 OpenAPI 3.0 响应 "links"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55839466/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com