Skip to content

Bad Pageable description in Page<DumbBuzModel> description #1215

Closed
@dtrouillet

Description

@dtrouillet

Describe the bug
When I use this library

        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-ui</artifactId>
            <version>1.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-data-rest</artifactId>
            <version>1.5.9</version>
        </dependency>

And this code :

    @GetMapping(value = "/search", produces = MediaType.APPLICATION_JSON_VALUE)
    @PreAuthorize("hasAnyRole('ROLE_USER','ROLE_ADMIN')")
    public Page<ApplicationSimpleDto> findApplication(@ParameterObject Pageable pageable, @QuerydslPredicate(root = Application.class) Predicate predicate) {
        LOGGER.debug("REST request to find Application - Read");
        return applicationService.findApplication(predicate, PaginationUtil.generatePageRequestOrDefault(pageable))
                .map(application -> mapper.map(application, ApplicationSimpleDto.class));
    }

the result is this schema :

 "content": [
    {
      "id": 34,
      "name": "test",
      "code": "ASD",
      "dateFichierPattern": "ddMMyyyy",
      "dateParametrePattern": "yyyyMMdd"
    },
    {
      "id": 36,
      "name": "test",
      "code": "AAA",
      "dateFichierPattern": "ddMMyyyy",
      "dateParametrePattern": "yyyyMMdd"
    },
    {
      "id": 135,
      "name": "Faya.fr",
      "code": "FA0",
      "dateFichierPattern": "yyyyMMdd",
      "dateParametrePattern": "yyyyMMdd"
    }
  ],
  "pageable": {
    "sort": {
      "sorted": false,
      "unsorted": true,
      "empty": true
    },
    "offset": 0,
    "pageNumber": 0,
    "pageSize": 20,
    "unpaged": false,
    "paged": true
  },
  "last": true,
  "totalPages": 1,
  "totalElements": 3,
  "size": 20,
  "number": 0,
  "sort": {
    "sorted": false,
    "unsorted": true,
    "empty": true
  },
  "first": true,
  "numberOfElements": 3,
  "empty": false
}

but in openapi spec generated it's this schemas (look at pageable description) :

{
  "totalPages": 0,
  "totalElements": 0,
  "size": 0,
  "content": [
    {
      "id": 0,
      "name": "string",
      "code": "string",
      "dateFichierPattern": "string",
      "dateParametrePattern": "string"
    }
  ],
  "number": 0,
  "sort": {
    "sorted": true,
    "unsorted": true,
    "empty": true
  },
  "first": true,
  "last": true,
  "numberOfElements": 0,
  "pageable": {
    "page": 0,
    "size": 1,
    "sort": [
      "string"
    ]
  },
  "empty": true
}

If I do not use springdoc-openapi-data-rest I don't have this trouble but I have no support for Pageable in parameters.

To Reproduce
Steps to reproduce the behavior:
You can use this repo : https://github.com/informatique-cdc/ebad/tree/feature/openapi_security and I had openapi description in attached file (is a yaml file).
openapi.txt

Expected behavior
The good behaviour is to have this :

{
  "totalPages": 0,
  "totalElements": 0,
  "size": 0,
  "content": [
    {
      "id": 0,
      "name": "string",
      "code": "string",
      "dateFichierPattern": "string",
      "dateParametrePattern": "string"
    }
  ],
  "number": 0,
  "sort": {
    "sorted": true,
    "unsorted": true,
    "empty": true
  },
  "first": true,
  "last": true,
  "numberOfElements": 0,
  "pageable": {
    "sort": {
      "sorted": false,
      "unsorted": true,
      "empty": true
    },
    "offset": 0,
    "pageNumber": 0,
    "pageSize": 20,
    "unpaged": false,
    "paged": true
  },
  "empty": true
}

Thanks a lot for your work :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions