端点响应代码片段

以 Markdown 格式查看

使用 <EndpointResponseSnippet> 组件来引用API文档中的端点响应。

用法

响应
1{
2 "turns": [
3 {
4 "role": "user",
5 "content": "string"
6 }
7 ],
8 "citations": [
9 "string"
10 ]
11}
Markdown
1<EndpointResponseSnippet endpoint="POST /chat/{domain}" />

引用特定示例

1

在规格中设置示例名称

openapi.yml
1paths:
2 /pet/{petId}:
3 put:
4 summary: Get a pet
5 operationId: pets_get
6 responses:
7 '200':
8 content:
9 application/json:
10 schema:
11 $ref: '#/components/schemas/Pet'
12 examples:
13 ExampleWithMarkley:
14 summary: This is an example of a Pet
15 value:
16 name: Markley
17 id: 44
pets.yml
1service:
2 auth: true
3 base-path: ""
4 endpoints:
5 update:
6 docs: Get a pet
7 method: GET
8 path: /pet/{petId}
9 response: Pet
10 examples:
11 - name: ExampleWithMarkley
12 docs: This is an example of a Pet
13 response:
14 body:
15 name: Markley
16 id: 44
2

直接引用示例

Markdown
1 <EndpointResponseSnippet
2 endpoint="GET /pet/{petId}"
3 example="ExampleWithMarkley"
4 />

属性

endpoint
stringRequired

要显示的端点,格式为 METHOD /path(例如,POST /chat/{domain})。如果你的API使用命名空间,请在前面加上命名空间和 ::(例如,payments::POST /chat/{domain})。

example
string

要显示的特定示例的名称。如果示例包含 summarydocs 字段,使用该值。

highlight
number | number[]

要在代码片段中高亮显示的行号。接受单个数字、数字数组或范围(例如,{[1-3, 5]})。