Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect representation of Sort property and SortObject in openapi after update to Spring Boot 3 #2763

Closed
mathsiv opened this issue Oct 14, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@mathsiv
Copy link

mathsiv commented Oct 14, 2024

I found a mismatch between the result of a call and the openapi documentation generated. The call should return a Page of MyDto, which contains a sort property.

Environment:

  • Spring Boot Version: 3.3.2
    springdoc-openapi Modules:
  • springdoc-openapi-starter-webmvc-ui 2.6.0
  • springdoc-openapi-maven-plugin 1.4

Here is an example of response i get with my call. No sorting is applied :

{
  "totalElements": 49,
  "totalPages": 1,
  "size": 50,
  "content": [],
  "number": 0,
  "sort": {
    "empty": true,
    "unsorted": true,
    "sorted": false
  },
  "pageable": {
    "pageNumber": 0,
    "pageSize": 50,
    "sort": {
      "empty": true,
      "unsorted": true,
      "sorted": false
    },
    "offset": 0,
    "unpaged": false,
    "paged": true
  },
  "first": true,
  "last": true,
  "numberOfElements": 49,
  "empty": false
}

As you can see, the sort property contains an object with empty, unosrted and sorted. But my openapi documentation tells me i should get something like this :

PageableObject:
  type: object
  properties:
    offset:
      type: integer
      format: int64
    sort:
      type: array
      items:
        $ref: "#/components/schemas/SortObject"
    pageSize:
      type: integer
      format: int32
    pageNumber:
      type: integer
      format: int32
    paged:
      type: boolean
    unpaged:
      type: boolean

SortObject:
  type: object
  properties:
    direction:
      type: string
    nullHandling:
      type: string
    ascending:
      type: boolean
    property:
      type: string
    ignoreCase:
      type: boolean

Pretty different. My openapi swagger used to also have the 3 properties empty, unsorted and sorted when I had spring boot 2 instead of 3 (I used springdoc-openapi-ui 1.6.11 and springdoc-openapi-maven-plugin 1.1), but then changed to this. I can't figure out why.

Expected :
I'd like my openapi documentation to actually reflect the object my call responds.

Could you help me figure out what i can do to fix this ?

Additional info :
While looking for a solution, i found this issue. It seems highly similar to mine.

@bnasslahsen
Copy link
Contributor

@mathsiv,

This is duplicate of #2725

That should be fixed with the next release v2.7.0

@bnasslahsen bnasslahsen added the duplicate This issue or pull request already exists label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants