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.13 Request Body 对象
创建时间: 2025-05-29 16:38
描述单个请求体。
4.8.13.1 固定字段
字段名称 | 类型 | 描述 |
---|---|---|
描述 | 字符串 | 请求体的简要描述。这可能包含使用示例。[CommonMark 规范] 语法可以用于富文本表示。 |
内容 | Map[string , 媒体类型对象] | 必需。请求体的内容。键是媒体类型或媒体类型范围,请参阅 [RFC7231] 附录 D,值描述它。对于匹配多个键的请求,仅适用最具体的键。例如,text/plain 覆盖 text/* |
必需 | 布尔值 | 确定请求中是否需要请求体。默认为 false 。 |
此对象*可以使用 规范扩展 进行扩展。
4.8.13.2 Request Body 示例
具有已引用模型定义的请求体。
{
"description": "user to add to the system",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/User"
},
"examples": {
"user" : {
"summary": "User Example",
"externalValue": "https://foo.bar/examples/user-example.json"
}
}
},
"application/xml": {
"schema": {
"$ref": "#/components/schemas/User"
},
"examples": {
"user" : {
"summary": "User example in XML",
"externalValue": "https://foo.bar/examples/user-example.xml"
}
}
},
"text/plain": {
"examples": {
"user" : {
"summary": "User example in Plain text",
"externalValue": "https://foo.bar/examples/user-example.txt"
}
}
},
"*/*": {
"examples": {
"user" : {
"summary": "User example in other format",
"externalValue": "https://foo.bar/examples/user-example.whatever"
}
}
}
}
}
description: user to add to the system
content:
'application/json':
schema:
$ref: '#/components/schemas/User'
examples:
user:
summary: User Example
externalValue: 'https://foo.bar/examples/user-example.json'
'application/xml':
schema:
$ref: '#/components/schemas/User'
examples:
user:
summary: User example in XML
externalValue: 'https://foo.bar/examples/user-example.xml'
'text/plain':
examples:
user:
summary: User example in Plain text
externalValue: 'https://foo.bar/examples/user-example.txt'
'*/*':
examples:
user:
summary: User example in other format
externalValue: 'https://foo.bar/examples/user-example.whatever'
作为字符串值数组的正文参数
{
"description": "user to add to the system",
"required": true,
"content": {
"text/plain": {
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
description: user to add to the system
required: true
content:
text/plain:
schema:
type: array
items:
type: string
最后更新: -