【发布时间】:2023-03-22 11:35:01
【问题描述】:
我使用 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
【问题讨论】:
-
你用的是什么版本的swagger?
-
我用的是2.0版本。
标签: rest swagger swagger-ui openapi