在spring应用程序中,我使用的是swagger2.6.1。
对于查询参数,我需要允许多个值。我用过allowMultiple= true。但是这会重复每个值的url中的参数名。
我需要发送一次参数名称,所有的值以逗号分隔的格式。
如何做到这一点
@RequestMapping(value = "/test", method = RequestMethod.GET)
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "testParam", value = "test parameter", dataType = "string", allowMultiple= true, allowableValues = "value1,value2,value3", paramType = "query"),
})
public String testMethod(){
// code
}现有url : http://localhost:8080/testApi/test?testParam=value1&testParam=value2&testParam=value3
必需的url : http://localhost:8080/testApi/test?testParam=value1,value2,value3
发布于 2021-08-16 10:32:27
尝试在注释@ApiImplicitParam中添加以下参数
collectionFormat = "Set"我使用了@ApiParam注释,它起作用了。
发布于 2019-11-11 09:41:44
在您的例子中,只有一个param testParam和值value1,value2,value3。
你想要做的是说,当只有1的时候,就有超过1的参数。
如果需要多个参数,请为它们使用唯一的名称,如param1、param2、param3
https://stackoverflow.com/questions/58749404
复制相似问题