0

I have a controller like so:

@GetMapping(value = "/list")
@PreAuthorize("@authService.hasPermission('read')")
public Page<SomeObject> getlist(
        @PageableDefault(page = 0, size = 10, sort = "id")
                Pageable pageable,
        @RequestHeader HttpHeaders headers) {
    log.info(pageable.toString());
    // Some code
}

Now when I hit this API endpoint with:

http://some-ip/list?pageNumber=1&pageSize=1

The pageable is not initialized with these values and I see the below log.

 Page request [number: 0, size 10, sort: id: ASC]

I have tried manually accepting the page size and number and building the pageable myself, that seems to work just fine but the pageable argument in my controller doesn't seem to get initialized. I have no clue why.

I have seen this thread already but it doesn't work for me.

Vivek Shankar
  • 770
  • 1
  • 15
  • 37
  • 2
    Your parameters are wrong, should be `page` and `size`. – M. Deinum Dec 04 '20 at 07:33
  • Thanks, @M.Deinum. I was just hitting it from a swagger UI and swagger generates the URL this way. Is there a change that I can do in the controller to work with this? I guess not. So this looks like a swagger issue then. Hmm.. – Vivek Shankar Dec 04 '20 at 08:26

0 Answers0