У меня есть этот код ...
@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>
Я ожидал, что параметры запроса будут выглядеть следующим образом ...
Обратите внимание, что типом in является «query», а не «body». Также имя верное.
{
"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>