Swagger你不会在Spring mvc的Get方法中发送参数吗?

时间:2016-07-02 15:35:45

标签: spring-mvc swagger swagger-ui springfox

我有一个有方法的spring mvc控制器。这个方法得到一些参数。我配置swagger并使用swagger来测试请求。当我想尝试请求参数时它不发送。

@RequestMapping(value = "/listGrid", method = RequestMethod.GET)
public QueryResult<ActionViewModel> list(String searchFilter, String order,
                    int pageNumber, int pageSize) {
    return actionService.getAllGridList(new SearchOption(searchFilter, 
                order, pageNumber, pageSize));
} 

为swigger请求生成的卷曲是

 curl -X GET --header 'Content-Type: application/json' --header 'Accept: */*' --header 'Authorization: Bearer 792a553e-b371-48a9-b031-12b634de4ce6' **-d '1'** 'http://localhost:8086/api/security/action/listGrid'

1 个答案:

答案 0 :(得分:3)

您是否尝试过在每个参数中添加requestParam注释?

@RequestMapping(value = "/listGrid", method = RequestMethod.GET)
public QueryResult<ActionViewModel> list(
    @RequestParam String searchFilter,
    @RequestParam String order, 
    @RequestParam int pageNumber,
    @RequestParam int pageSize) {
    // body
}