如何在 Swagger UI 中使用 OpenAPI 3.0 响应 "links"?
How to use OpenAPI 3.0 response "links" in Swagger UI?
我正在编写 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
像这样呈现 link:
这是预期的吗?我问是因为 operationId
暴露在 UI 上,而 parameters
显示为 JSON 引用,所以看起来有些东西没有正确显示。我本以为 hyperlink 或其他东西会将我带到 Swagger 网页中对应于 link.
引用的 API 的相应部分
是的,这就是 Swagger UI 当前呈现 OAS3 links
的方式。 links
的渲染是 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
我正在编写 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
像这样呈现 link:
这是预期的吗?我问是因为 operationId
暴露在 UI 上,而 parameters
显示为 JSON 引用,所以看起来有些东西没有正确显示。我本以为 hyperlink 或其他东西会将我带到 Swagger 网页中对应于 link.
是的,这就是 Swagger UI 当前呈现 OAS3 links
的方式。 links
的渲染是 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