假设我有一个Pagination<T>
类型用于列表端点。现在,假设我有/Users
,它应该返回Pagination<User>
。如何定义响应?这样做只是部分:
responses:
200:
description: OK
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/Pagination'
这不知道分页的类型。我正在使用Swagger批注来生成该批注,因此我想使解决方案与批注一起使用。我知道我可能可以创建一个自定义组件,例如
UserList:
type: object
properties:
result:
type: array
items:
$ref: '#/components/schemas/User'
meta:
$ref: '#/components/schemas/PagingMetadata'
然后更新上面的内容以引用该对象,但是我自己在.yaml文件中手工制作了此对象,我想使解决方案与注释一起使用。