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.9 Path Item 对象
创建时间: 2025-05-29 16:38
描述单个路径上可用的操作。由于ACL 约束,路径项可以为空。路径本身仍然公开给文档查看器,但他们将不知道哪些操作和参数可用。
4.8.9.1 固定字段
字段名称 | 类型 | 描述 |
---|---|---|
$ref | 字符串 | 允许此路径项的引用定义。引用的结构必须为路径项对象格式。如果定义的对象和引用的对象中都出现了路径项对象字段,则行为未定义。请参阅解析相对引用的规则。 |
摘要 | 字符串 | 一个可选的字符串摘要,旨在应用于此路径中的所有操作。 |
描述 | 字符串 | 一个可选的字符串描述,旨在应用于此路径中的所有操作。[CommonMark 规范] 语法可以用于富文本表示。 |
get | 操作对象 | 在此路径上定义 GET 操作。 |
put | 操作对象 | 在此路径上定义 PUT 操作。 |
post | 操作对象 | 在此路径上定义 POST 操作。 |
delete | 操作对象 | 在此路径上定义 DELETE 操作。 |
options | 操作对象 | 在此路径上定义 OPTIONS 操作。 |
head | 操作对象 | 在此路径上定义 HEAD 操作。 |
patch | 操作对象 | 在此路径上定义 PATCH 操作。 |
trace | 操作对象 | 在此路径上定义 TRACE 操作。 |
服务器 | [服务器对象] | 此路径中所有操作的服务的备用 server 数组。 |
参数 | 参数对象 引用对象 | 此路径下描述的所有操作都适用的参数列表。这些参数可以在操作级别覆盖,但不能在那里删除。列表不得包含重复的参数。唯一参数由名称和位置的组合定义。该列表可以使用引用对象链接到在OpenAPI 对象的 components/parameters中定义的参数。 |
此对象*可以使用 规范扩展 进行扩展。
4.8.9.2 Path Item 对象示例
{
"get": {
"description": "Returns pets based on ID",
"summary": "Find pets by ID",
"operationId": "getPetsById",
"responses": {
"200": {
"description": "pet response",
"content": {
"*/*": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Pet"
}
}
}
}
},
"default": {
"description": "error payload",
"content": {
"text/html": {
"schema": {
"$ref": "#/components/schemas/ErrorModel"
}
}
}
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"description": "ID of pet to use",
"required": true,
"schema": {
"type": "array",
"items": {
"type": "string"
}
},
"style": "simple"
}
]
}
get:
description: Returns pets based on ID
summary: Find pets by ID
operationId: getPetsById
responses:
'200':
description: pet response
content:
'*/*' :
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
default:
description: error payload
content:
'text/html':
schema:
$ref: '#/components/schemas/ErrorModel'
parameters:
- name: id
in: path
description: ID of pet to use
required: true
schema:
type: array
items:
type: string
style: simple
最后更新: -