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.8 Paths 对象
创建时间: 2025-05-29 16:38
4.8.8.1 模式化字段
字段模式 | 类型 | 描述 |
---|---|---|
/{path} | 路径项对象 | 到单个端点的相对路径。字段名称必须以正斜杠 (/ ) 开头。路径附加(无相对 URL 解析)到Server 对象 的 url 字段中扩展的 URL 以构建完整 URL。路径模板是允许的。在匹配 URL 时,将先匹配具体的(非模板化的)路径,然后再匹配其模板化的对应路径。具有相同层次结构但不同模板名称的模板化路径不得存在,因为它们是相同的。在出现歧义匹配的情况下,由工具决定使用哪一个。 |
此对象*可以使用 规范扩展 进行扩展。
4.8.8.2 路径模板匹配
假设以下路径,如果使用具体的定义 /pets/mine
,则将首先匹配它
/pets/{petId}
/pets/mine
以下路径被认为是相同的且无效的
/pets/{petId}
/pets/{name}
以下可能导致歧义解析
/{entity}/me
/books/{id}
4.8.8.3 Paths 对象示例
{
"/pets": {
"get": {
"description": "Returns all pets from the system that the user has access to",
"responses": {
"200": {
"description": "A list of pets.",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/pet"
}
}
}
}
}
}
}
}
}
/pets:
get:
description: Returns all pets from the system that the user has access to
responses:
'200':
description: A list of pets.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/pet'
最后更新: -