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.19 Example 对象
创建时间: 2025-05-29 16:38
4.8.19.1 固定字段
字段名称 | 类型 | 描述 |
---|---|---|
摘要 | 字符串 | 示例的简短描述。 |
描述 | 字符串 | 示例的详细描述。[CommonMark] 语法可以用于富文本表示。 |
值 | 任何 | 嵌入的文字示例。value 字段和externalValue 字段是互斥的。要表示无法以 JSON 或 YAML 自然表示的媒体类型的示例,请使用字符串值包含示例,并在必要时进行转义。 |
外部值 | 字符串 | 指向文字示例的 URI。这提供了引用无法轻松包含在 JSON 或 YAML 文档中的示例的功能。value 字段和externalValue 字段是互斥的。请参阅解析相对引用的规则。 |
此对象*可以使用 规范扩展 进行扩展。
在所有情况下,示例值都应与其关联值的类型模式兼容。工具实现可以选择自动验证兼容性,并在不兼容时拒绝示例值。
4.8.19.2 Example 对象示例
在请求主体中
requestBody:
content:
'application/json':
schema:
$ref: '#/components/schemas/Address'
examples:
foo:
summary: A foo example
value: {"foo": "bar"}
bar:
summary: A bar example
value: {"bar": "baz"}
'application/xml':
examples:
xmlExample:
summary: This is an example in XML
externalValue: 'https://example.org/examples/address-example.xml'
'text/plain':
examples:
textExample:
summary: This is a text example
externalValue: 'https://foo.bar/examples/address-example.txt'
在参数中
parameters:
- name: 'zipCode'
in: 'query'
schema:
type: 'string'
format: 'zip-code'
examples:
zip-example:
$ref: '#/components/examples/zip-example'
在响应中
responses:
'200':
description: your car appointment has been booked
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessResponse'
examples:
confirmation-success:
$ref: '#/components/examples/confirmation-success'
最后更新: -