Skip to content

Conversation

@aanno2
Copy link

@aanno2 aanno2 commented Nov 11, 2019

springdoc-openapi maps the spring Pageable like any other scheme. However according to [1] this type needs special handling.

I have fixed that by implementing the ModelConverter PageableSupportConverter that will replace the 'real' type org.springframework.data.domain.Pageable with an appropriate replacement type.

[1] https://docs.spring.io/spring-data/rest/docs/3.2.1.RELEASE/reference/html/#paging-and-sorting

@aanno2
Copy link
Author

aanno2 commented Nov 11, 2019

BTW, you could test that with app2 of springdoc/springdoc-openapi-demos#2

This is the relevant JSON with the fix:

      "Pageable": {
        "required": [
          "page",
          "size"
        ],
        "type": "object",
        "properties": {
          "page": {
            "minimum": 0,
            "type": "integer",
            "format": "int32"
          },
          "size": {
            "maximum": 2000,
            "minimum": 1,
            "type": "integer",
            "format": "int32"
          },
          "sort": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },

@springdoc
Copy link
Collaborator

Hello,

Thank for your contribution. Your proposal works fine because you have introduced your custom implementation of Pageable.

Additionally, the custom converter handles a class of spring-data-commons, which springdoc-openapi do not rely on.
We believe that implementation of custom converters should stay local to each project, in this case.

@springdoc springdoc closed this Nov 17, 2019
@springdoc
Copy link
Collaborator

Finally, we have added the support of Pageable on a specefic module. #177

@aanno2
Copy link
Author

aanno2 commented Dec 2, 2019

Just for the records:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants