我使用Swagger描述了我的控制器,但是当我试图提取控制器的.yaml描述时,作为端点的响应,我找到了对象列表。如何使Swagger将这些列表描述为特定对象的列表,如汽车列表、房屋列表、动物列表等,然后描述什么是汽车、房子或动物等特定对象。我的案例是:
/dummy_endpoint:
get:
tags:
- foo-controller
summary: Get foo list
description: Send GET request to obtain foo list
operationId: findAllFooUsingGET
produces:
- application/json
responses:
'200':
description: Foo list obtained successfully
schema:
type: array
items:
type: object
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found我想要的是:
/dummy_endpoint:
get:
tags:
- foo-controller
summary: Get foo list
description: Send GET request to obtain foo list
operationId: findAllFooUsingGET
produces:
- application/json
responses:
'200':
description: Foo list obtained successfully
schema:
type: array
items:
type: Foo
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
definitions:
Foo:
type: object
properties:
id:
type: integer
format: int32
name:
type: String发布于 2021-12-17 12:38:55
发布于 2021-12-20 10:53:27
解决我问题的是使用@ResponseApi注释中的responseContainer属性,其中我将类型的响应容器(如List、Array等)放入到存储在容器中的对象的响应属性类型中。
https://stackoverflow.com/questions/70393165
复制相似问题