Search code examples
javarestswaggerspringfox

Swagger or springfox ignore Pageable param


I am trying to construct swagger documentation using springfox.

My rest method is

@RequestMapping(value = "/filter", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public final Page<SomeOtherObj> filter(@RequestBody SomeObj dto, Pageable pageable) {...}

and in output I have documentation with parametr list:

"parameters": [
    {
        "in": "body",
        "name": "dto",
        "description": "dto",
        "required": true,
        "schema": {
            "$ref": "#/definitions/SomeOdj"
        }
    }
],

Where is Pageable? Why does it ignore by swagger?


Solution

  • My guess is since it's not marked with @RequestBody it's getting ignored. Anyway, you can implicitly mark it with @ApiParam annotation. It should be included to final spec.

    @RequestMapping(value = "/filter", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public final Page<SomeOtherObj> filter(@RequestBody SomeObj dto, @ApiParam(name = "Pageable filter", required = false) Pageable pageable) {...}
    

    Update

    As per comments

    Issues happens in v 2.8.0. Everything is OK in new version 2.9.0 of Springfox Swagger. And it works fine in older versions (I tried 2.6.1)