|
|
气宇轩昂的跑步鞋 · Spring 嵌套事务 ...· 2 年前 · |
|
|
活泼的楼梯 · 海康工业相机 python ...· 2 年前 · |
|
|
温柔的铁板烧 · mysql - mysqldump ...· 3 年前 · |
我使用的SpringBoot具有以下依赖项
<dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-ui</artifactId> <version>1.5.12</version> </dependency>
控制器类(@RestController)有一个入口点(@ return ),这个入口点应该返回对象的列表: MyClass.java 。我在方法上面添加了Swagger注释,以便通过swagger页面创建API文档。
swagger文档应指示返回对象的类型。
List< MyClass>
但我该怎么做呢?如果我做了
@Schema(implementation= List< MyClass >.class)
编译错误。
摆动注释:
@operation(.)@ApiResponse(value={ @ApiResponse(responseCode = "200",description = "successful“),content ={ @Content(mediaType = "application/json",schema = @Schema(implementation =?) }),@ApiResponse(.),@ApiResponse(.)@/aaa,MediaType.APPLICATION_JSON_VALUE)公共列表getAaa(.){返回.}
发布于 2021-11-01 17:26:42
为此,您需要使用
ArraySchema
注释,并将其分配给
array
属性,而不是
@Content
注释的
schema
属性。您不需要只指定
List.class
的类型参数
MyClass.class
。
@Operation(
summary = "Get a list of users",
description = "Get a list of users registered in the system",
responses = {@ApiResponse(
responseCode = "200",
description = "The response for the user request",
content = {
@Content(
mediaType = "application/json",
array = @ArraySchema(schema = @Schema(implementation = User.class))