扩展参考
GitBook 支持的 OpenAPI 扩展的完整参考
您可以使用扩展来增强您的 OpenAPI 规范——这些自定义字段以 x- 前缀开头。这些扩展允许您添加额外信息并根据不同需求定制您的 API 文档。
GitBook 允许您通过向 OpenAPI 规范添加各种扩展来调整已发布站点上 API 的外观和行为。
前往我们的 指南部分 了解有关使用 OpenAPI 扩展来配置文档的更多信息。
x-page-title | x-displayName
更改用于导航和页面标题的标签显示名称。
openapi.yaml
openapi: '3.0'
info: ...
tags:
- name: users
x-page-title: Usersx-page-description
为页面添加描述。
openapi.yaml
openapi: '3.0'
info: ...
tags:
- name: "users"
x-page-title: "Users"
x-page-description: "管理用户账户和个人资料。"x-page-icon
为页面添加 Font Awesome 图标。可用图标请参见 此处.
openapi.yaml
openapi: '3.0'
info: ...
tags:
- name: "users"
x-page-title: "Users"
x-page-description: "管理用户账户和个人资料。"
x-page-icon: "user"parent | x-parent
为标签添加层级,以便在 GitBook 中组织页面。
parent 是 OpenAPI 3.2+ 中的官方属性名称。如果使用 3.2 之前的 OpenAPI 版本(3.0.x、3.1.x),请使用 x-parent 代替。
openapi.yaml
openapi: '3.2'
info: ...
tags:
- name: organization
- name: admin
parent: organization
- name: user
parent: organization x-hideTryItPanel
显示或隐藏 OpenAPI 模块的“测试它”按钮。
openapi.yaml
openapi: '3.0'
info: ...
tags: [...]
paths:
/example:
get:
summary: Example summary
description: Example description
operationId: examplePath
responses: [...]
parameters: [...]
x-hideTryItPanel: truex-codeSamples
显示、隐藏或为 OpenAPI 模块包含自定义代码示例。
字段
字段名称
类型
描述
openapi.yaml
openapi: '3.0'
info: ...
tags: [...]
paths:
/example:
get:
summary: Example summary
description: Example description
operationId: examplePath
responses: [...]
parameters: [...]
x-codeSamples:
- lang: 'cURL'
label: 'CLI'
source: |
curl -L \
-H 'Authorization: Bearer <token>' \
'https://api.gitbook.com/v1/user'x-enumDescriptions
为模式中的每个 枚举 值添加单独描述。
openapi.yaml
openapi: '3.0'
info: ...
components:
schemas:
project_status:
type: string
enum:
- LIVE
- PENDING
- REJECTED
x-enumDescriptions:
LIVE: The project is live.
PENDING: The project is pending approval.
REJECTED: The project was rejected.x-internal | x-gitbook-ignore
在您的 API 参考中隐藏某个端点。
openapi.yaml
openapi: '3.0'
info: ...
tags: [...]
paths:
/example:
get:
summary: Example summary
description: Example description
operationId: examplePath
responses: [...]
parameters: [...]
x-internal: truex-stability
标记不稳定或正在进行中的端点。
支持的值: experimental, alpha, beta.
openapi.yaml
openapi: '3.0'
info: ...
tags: [...]
paths:
/example:
get:
summary: Example summary
description: Example description
operationId: examplePath
x-stability: experimentaldeprecated
标记端点是否已弃用。已弃用的端点将在您发布的站点中显示弃用警告。
openapi.yaml
openapi: '3.0'
info: ...
tags: [...]
paths:
/example:
get:
summary: Example summary
description: Example description
operationId: examplePath
responses: [...]
parameters: [...]
deprecated: truex-deprecated-sunset
为已弃用的操作添加结束(下线)日期。
支持的值: ISO 8601 格式(YYYY-MM-DD)
openapi.yaml
openapi: '3.0'
info: ...
tags: [...]
paths:
/example:
get:
summary: Example summary
description: Example description
operationId: examplePath
responses: [...]
parameters: [...]
deprecated: true
x-deprecated-sunset: 2030-12-05最后更新于
这有帮助吗?