我想用架构或示例扩展“200SuccessDefault”响应。
paths:
/home:
...
responses:
200:
$ref: '#/components/responses/200SuccessDefault'
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PieChartElement'
examples:
PieChart:
$ref: '#/components/examples/PieChart_1'
Run Code Online (Sandbox Code Playgroud)
这种方法会遇到错误,schema和examples字段被忽略:
与 $refs 一起的同级值将被忽略。要将属性添加到 $ref,请将 $ref 包装到 allOf 中,或将额外的属性移动到引用的定义中(如果适用)。
我试过allOf:
paths:
/home:
responses:
200:
allOf:
- $ref: '#/components/responses/200SuccessDefault'
- content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PieChartElement'
examples:
PieChart:
$ref: '#/components/examples/PieChart_1'
Run Code Online (Sandbox Code Playgroud)
这种方法会遇到错误:
不应该有额外的属性additionalProperty:allOf
应该有必需的属性'description'missingProperty:description