[英]How to specify a list using OpenAPI 3 Swagger annotations
For my API I'm making a meta annotation for handling Pagable
parameters and for it I need to annotate a list of strings as a parameter that will show up in Swagger UI.对于我的 API,我正在制作一个元注释来处理Pagable
参数,为此我需要将字符串列表注释为将显示在 Swagger UI 中的参数。
import io.swagger.v3.oas.annotations.Parameter;
@Parameter(name = "sort", in = ParameterIn.QUERY, schema = @Schema(implementation = String.class, type = "query"))
public @interface PageableQueryParameters {}
In order to sort by multiple criteria in Spring's Pageable
the sort parameter needs to be provided as a list of strings.为了在 Spring 的Pageable
按多个条件进行排序,需要将 sort 参数作为字符串列表提供。 Unfortunately I don't know how to declare the sort parameter as a list.不幸的是,我不知道如何将 sort 参数声明为列表。
How can I document a list of strings using Swagger's OpenAPI 3 annotations?如何使用 Swagger 的 OpenAPI 3 注释记录字符串列表?
If I'm understanding you correctly, to indicate that the "sort"
parameter is a list, you need to use the parameters array
like the following:如果我对你的理解正确,为了表明"sort"
参数是一个列表,你需要使用如下所示的参数array
:
schema = @Schema(implementation = String.class, type = "query"
should be changed to应该改为
array = @ArraySchema(implementation = String.class)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.