端点响应代码片段

以 Markdown 格式查看

使用 <EndpointResponseSnippet> 组件从你的 API 参考中引用端点响应。

使用方法

响应
1{
2 "turns": [
3 {
4 "role": "user",
5 "content": "Can you explain the benefits of using renewable energy sources?"
6 },
7 {
8 "role": "assistant",
9 "content": "Renewable energy sources, such as solar and wind power, provide sustainable and environmentally friendly alternatives to fossil fuels. They help reduce greenhouse gas emissions, decrease air pollution, and promote energy independence."
10 }
11 ],
12 "citations": [
13 "https://www.epa.gov/greenpower/benefits-green-power",
14 "https://www.irena.org/renewable-energy"
15 ]
16}
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
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]})。