我正在使用SwaggerHub和OpenAPI 3来定义API。一条路线
GET /foo/{id]
,应返回
foo
给定对象
id
,及其关联
bar
{id: 4, name: 'test', bars: [{id: 53, name: 'barName1'}, {id: 87, name: 'barName2'}]}
.也就是说,在
和
我如何用OpenAPI 3语法描述这一点?我试过用
anyOf
paths:
/foo/{id}:
get:
parameters:
- name: id
in: path
required: true
schema:
type: integer
responses:
'200':
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Foo'
anyOf:
- $ref: '#/components/schemas/Bar'
但这似乎没有在用户界面中显示正确的模式(没有提到
Bar