Java 如何为请求参数允许多个预定义(枚举)值?

Java 如何为请求参数允许多个预定义(枚举)值?,java,springdoc,springdoc-openapi-ui,Java,Springdoc,Springdoc Openapi Ui,我希望接收查询字符串参数的多个值,例如: /api/assets?category=light&category=heavy 同时将允许的值约束到预定义集 我已经找到了,现在如何允许输入多个值 这是我当前的代码: public ApiRespSuccess<List<AssetApi>, ApiMetadataPagination> getAssets( @RequestParam @Parameter(schema=@Schema(descri

我希望接收查询字符串参数的多个值,例如:

/api/assets?category=light&category=heavy
同时将允许的值约束到预定义集

我已经找到了,现在如何允许输入多个值

这是我当前的代码:

public ApiRespSuccess<List<AssetApi>, ApiMetadataPagination> getAssets(
        @RequestParam @Parameter(schema=@Schema(description="param-desc", type="string", allowableValues= {"positioning", "energyReport"})) List<String> withExtFeature,
        @ParameterObject RequestPagination pagination) {
        // ...
公共资产(
@RequestParam@Parameter(schema=@schema(description=“param desc”,type=“string”,allowableValues={“positioning”,“energyReport”}))列表中包含extfeature,
@参数对象请求分页(分页){
// ...

如果我删除@Parameter注释,swagger ui将显示一个“添加项目”按钮。

这是实现目标的语法:

@GetMapping("/test")
public SampleDTO getFile(@RequestParam @Parameter(array = @ArraySchema(schema = @Schema(type = "string", allowableValues= {"positioning", "energyReport"})), description="param-desc") List<String> withExtFeature){
    return null;
}
@GetMapping(“/test”)
public SampleDTO getFile(@RequestParam@Parameter(array=@ArraySchema(schema=@schema(type=“string”,allowableValues={“positioning”,“energyReport”})),description=“param desc”)列表和extfeature){
返回null;
}

这是实现目标的方法:

@GetMapping("/test")
public SampleDTO getFile(@RequestParam @Parameter(array = @ArraySchema(schema = @Schema(type = "string", allowableValues= {"positioning", "energyReport"})), description="param-desc") List<String> withExtFeature){
    return null;
}
@GetMapping(“/test”)
public SampleDTO getFile(@RequestParam@Parameter(array=@ArraySchema(schema=@schema(type=“string”,allowableValues={“positioning”,“energyReport”})),description=“param desc”)列表和extfeature){
返回null;
}

通常你会做一些类似于
?category=light,heavy
,而不是复制请求标记(正如我想象的那样,许多API最终只会看到一个
heavy
标记)@Rogue会生成一个不同的卷曲。通常你会做一些类似于
?category=light,heavy
,而不是复制请求标记(正如我想象的那样,许多API最终只会看到一个
沉重的
标记)@Rogue-Well生成一个不同的卷曲。