OpenAPI 规范 v3.1.0
OpenAPI 规范 v3.1.0
1. OpenAPI 规范
2. 简介
3. 定义
4. 规范
4.1 版本
4.2 格式
4.3 文档结构
4.4 数据类型
4.5 富文本格式化
4.6 URI 中的相对引用
4.7 URL 中的相对引用
4.8 模式
4.8.1 OpenAPI 对象
4.8.2 Info 对象
4.8.3 Contact 对象
4.8.4 License 对象
4.8.5 Server 对象
4.8.6 Server Variable 对象
4.8.7 Components 对象
4.8.8 Paths 对象
4.8.9 Path Item 对象
4.8.10 Operation 对象
4.8.11 External Documentation 对象
4.8.12 Parameter 对象
4.8.13 Request Body 对象
4.8.14 Media Type 对象
4.8.15 Encoding 对象
4.8.16 Responses 对象
4.8.17 Response 对象
4.8.18 Callback 对象
4.8.19 Example 对象
4.8.20 Link 对象
4.8.21 Header 对象
4.8.22 Tag 对象
4.8.23 Reference 对象
4.8.24 Schema 对象
4.8.25 Discriminator 对象
4.8.26 XML 对象
4.8.27 Security Scheme 对象
4.8.28 OAuth Flows 对象
4.8.29 OAuth Flow 对象
4.8.30 Security Requirement 对象
4.9 规范扩展
4.10 安全过滤
4.8.17 Response 对象
创建时间: 2025-05-29 16:38
描述来自 API 操作的单个响应,包括基于响应的操作的设计时静态 链接。
4.8.17.1 固定字段
字段名称 | 类型 | 描述 |
---|---|---|
description | 字符串 | 必需。响应的描述。[CommonMark] 语法可以用于富文本表示。 |
headers | Map[string , 头部对象 引用对象] | 将标头名称映射到其定义。[RFC7230] 第 22 页 指出标头名称不区分大小写。如果使用名称 "Content-Type" 定义了响应标头,则必须忽略它。 |
content | Map[string , 媒体类型对象] | 包含潜在响应有效负载描述的地图。键是媒体类型或媒体类型范围,请参阅[RFC7231] 附录 D,其值描述了它。对于匹配多个键的响应,只有最具体的键适用。例如,text/plain 覆盖 text/*。 |
链接 | Map[string , 链接对象 引用对象] | 可以从响应中跟随的操作链接的映射。映射的键是链接的简称,遵循组件对象名称的命名约束。 |
此对象*可以使用 规范扩展 进行扩展。
*4.8.17.2 Response 对象示例
复杂类型数组的响应
{
"description": "A complex object array response",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/VeryComplexType"
}
}
}
}
}
description: A complex object array response
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/VeryComplexType'
带有字符串类型的响应
{
"description": "A simple string response",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
}
}
}
description: A simple string response
content:
text/plain:
schema:
type: string
带有标头的纯文本响应
{
"description": "A simple string response",
"content": {
"text/plain": {
"schema": {
"type": "string",
"example": "whoa!"
}
}
},
"headers": {
"X-Rate-Limit-Limit": {
"description": "The number of allowed requests in the current period",
"schema": {
"type": "integer"
}
},
"X-Rate-Limit-Remaining": {
"description": "The number of remaining requests in the current period",
"schema": {
"type": "integer"
}
},
"X-Rate-Limit-Reset": {
"description": "The number of seconds left in the current period",
"schema": {
"type": "integer"
}
}
}
}
description: A simple string response
content:
text/plain:
schema:
type: string
example: 'whoa!'
headers:
X-Rate-Limit-Limit:
description: The number of allowed requests in the current period
schema:
type: integer
X-Rate-Limit-Remaining:
description: The number of remaining requests in the current period
schema:
type: integer
X-Rate-Limit-Reset:
description: The number of seconds left in the current period
schema:
type: integer
没有返回值的响应
{
"description": "object created"
}
description: object created
最后更新: -