Search code examples
spring-mvcswaggerswagger-uispringfox

Swagger you don't send parameters in Get method in spring mvc?


I have spring mvc controller that have a method. This method get some parameter. I configure swagger and using swagger for test a request.When I want to try request parameter it does not send.

@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));
} 

curl that generate for request by swagger is this

 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'

Solution

  • Did you try it adding the requestParam annotation in each paramaters?

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