扩展参考
GitBook 支持的 OpenAPI 扩展完整参考
你可以使用扩展来增强你的 OpenAPI 规范——这些自定义字段以 x- 前缀开头。这些扩展可让你添加额外信息,并根据不同需求定制你的 API 文档。
GitBook 允许你通过可添加到 OpenAPI 规范中的多种不同扩展,调整你的 API 在已发布站点上的外观和行为。
前往我们的 指南部分 ,了解更多如何使用 OpenAPI 扩展来配置你的文档。
最后更新于
这有帮助吗?
这有帮助吗?
openapi: '3.0'
info: ...
# 为每个操作展开所有响应
x-expandAllResponses: true
paths:
/pets:
get:
summary: 列出宠物
responses: [...]
# 对单个操作禁用
x-expandAllResponses: falseopenapi: '3.0'
info: ...
# 为每个操作展开所有模型部分
x-expandAllModelSections: true
paths:
/pets:
post:
summary: 创建宠物
requestBody: [...]
responses: [...]
# 对单个操作禁用
x-expandAllModelSections: falseopenapi: '3.0.3'
info: ...
# 为所有操作启用代理
x-enable-proxy: true
paths:
/health:
get:
summary: 健康检查
# 对单个操作禁用
x-enable-proxy: false
responses:
'200':
description: 成功openapi: '3.0'
info: ...
tags: [...]
paths:
/example:
get:
summary: 示例摘要
description: 示例描述
operationId: examplePath
responses: [...]
parameters: [...]
x-codeSamples:
- lang: 'cURL'
label: 'CLI'
source: |
curl -L \\
-H 'Authorization: Bearer <token>' \\
'https://api.gitbook.com/v1/user'openapi: '3.0'
info: ...
components:
schemas:
project_status:
type: string
enum:
- LIVE
- PENDING
- REJECTED
x-enumDescriptions:
LIVE:项目已上线。
PENDING:项目待批准。
REJECTED:项目已被拒绝。openapi: '3.0'
info: ...
tags: [...]
paths:
/example:
get:
summary: 示例摘要
description: 示例描述
operationId: examplePath
responses: [...]
parameters: [...]
x-internal: trueopenapi: '3.0'
info: ...
tags: [...]
paths:
/example:
get:
summary: 示例摘要
description: 示例描述
operationId: examplePath
x-stability: experimentalopenapi: '3.0'
info: ...
tags: [...]
paths:
/example:
get:
summary: 示例摘要
description: 示例描述
operationId: examplePath
responses: [...]
parameters: [...]
deprecated: trueopenapi: '3.0'
info: ...
tags: [...]
paths:
/example:
get:
summary: 示例摘要
description: 示例描述
operationId: examplePath
responses: [...]
parameters: [...]
deprecated: true
x-deprecated-sunset: 2030-12-05