Skip to content

Description for Pageable parameters is not displayed in swagger-ui #543

Closed
@valentinabojan

Description

@valentinabojan

Hi!

I'm trying to setup springdoc-openapi in my project and I'm facing an issue regarding the Pageable object.
Used dependencies:

  • springdoc-openapi-ui - 1.3.1
  • springdoc-openapi-data-rest - 1.3.1

Looking here, I see that I should have the following configuration:

@PageableAsQueryParam
public PagedModel<Person> getPersons(@Parameter(hidden = true) Pageable pageable) {...}

This will generate the following (that will be displayed as expected in swagger-ui, every parameter having the description next to it):

"parameters": [
{
  "name": "page",
  "in": "query",
  "description": "Zero-based page index (0..N)",
  "schema": {
    "type": "integer",
    "default": "0"
  }
},
{
  "name": "size",
  "in": "query",
  "description": "The size of the page to be returned",
  "schema": {
    "type": "integer",
    "default": "20"
  }
},
{
  "name": "sort",
  "in": "query",
  "description": "Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported.",
  "schema": {
    "type": "array",
    "items": {
      "type": "string"
    }
  }
}
]

However, the PageableAsQueryParam seems to be deprecated in 1.3.1 and following the javadocs, I updated the above configuration with the one below:

public PagedModel<Person> getPersons(@ParameterObject Pageable pageable) {...}

This time, the generated docs look a bit different:

"parameters": [
{
  "name": "page",
  "in": "query",
  "required": false,
  "schema": {
    "minimum": 0,
    "type": "integer",
    "description": "Zero-based page index (0..N)",
    "format": "int32",
    "default": 0
  }
},
{
  "name": "size",
  "in": "query",
  "required": false,
  "schema": {
    "maximum": 2000,
    "minimum": 1,
    "type": "integer",
    "description": "The size of the page to be returned",
    "format": "int32",
    "default": 20
  }
},
{
  "name": "sort",
  "in": "query",
  "required": false,
  "schema": {
    "type": "array",
    "description": "Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported.",
    "items": {
      "type": "string"
    }
  }
}
]

The problem that I'm facing now (with the above configuration that is not using @PageableAsQueryParam anymore) is that the parameters description are not displayed anymore in swagger-ui (maybe because now the description is at the schema level and not at the parameter level?).

Am I missing something? Is there anything wrong with the way I try to configure swaggerdocs for Pageble? Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions