我有这个代码...
@RequestMapping(value = "/search/",
method = RequestMethod.GET,
produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Search for a Device",
response = DeviceSummary.class,
position = 0)
List<DeviceSummary> search(@ApiParam(value = "The store code", required = true) @QueryParam("storeCode") String storeCode,
@ApiParam(value = "The device type code", required = false) @QueryParam("deviceType") String deviceType,
@ApiParam(value = "The device type codes", required = false) @QueryParam("deviceTypes") String deviceTypes,
@ApiParam(value = "The device group code", required = false) @QueryParam("deviceGroupCode") String deviceGroupCode,
@ApiParam(value = "Max results to return", required = false) @QueryParam("maxResults") String maxResults);
swagger.json文件如下所示。
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "The store code",
"required" : true,
"schema" : {
"type" : "string"
}
}, {
"in" : "body",
"name" : "body",
"description" : "The device type code",
"required" : false,
"schema" : {
"type" : "string"
}
}, <SNIP>
我期望查询参数看起来像这样... 请注意,“输入”类型是“查询”,而不是“正文”。而且,名称正确。
{
"name" : "storeCode",
"in" : "query",
"description" : "The store code",
"required" : true,
"type" : "string"
}
我正在使用这些依赖项
<dependency>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<scope>compile</scope>
<version>1.5.3</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
答案 0 :(得分:0)
答案是不要混合JaxRS和Spring注释。
应该是... @ RequestParam,而不是@QueryParam
@ApiParam(value = "The store code", required = true) @RequestParam("storeCode") String storeCode,