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.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
最后更新: -