Skip to content

Pageable required #561

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

Closed
kfirfer opened this issue Apr 12, 2020 · 5 comments
Closed

Pageable required #561

kfirfer opened this issue Apr 12, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@kfirfer
Copy link

kfirfer commented Apr 12, 2020

Hello

I'm using springdoc-openapi-ui version 1.3.2
& springdoc-openapi-data-rest 1.3.2

And I encountered that "Pageable" parameters size, page and sort are required
I can see it here:
https://github.com/springdoc/springdoc-openapi/blob/master/springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/converters/Pageable.java

Does it should be required?
If I don't pass them , spring inject its defaults values and can be overriden from äpplication.yaml:
spring: data: rest: default-page-size: 20 max-page-size: 1000

@kfirfer kfirfer changed the title https://github.com/springdoc/springdoc-openapi/blob/master/springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/converters/Pageable.java#L47 Pageable required Apr 13, 2020
@bnasslahsen
Copy link
Collaborator

Hi @kfirfer,

Yes, the Pageable attributes are required.
But there are default values already set, on the swagger-ui.

@kfirfer
Copy link
Author

kfirfer commented Apr 13, 2020

the sort is also required and quite annoying to set it with empty value in order to fire a request , also if I override the default values in spring application.yaml it is not reflected in the defaults of Pageable

@kfirfer
Copy link
Author

kfirfer commented Apr 13, 2020

I dont think the attributes should be required , since spring make the defaults by its own

@kfirfer
Copy link
Author

kfirfer commented Apr 13, 2020

I think the best solution is to give the user to decide the parameters in the object

@bnasslahsen
Copy link
Collaborator

bnasslahsen commented Apr 13, 2020

@kfirfer,

You can use @PageableAsQueryParam annotation, in conjunction with @parameter(hidden = true). This can help you achieve what you want.

If you can see this request, it explains why we have these constaints.

Even all these attributes (page, sort, size) must not be null, spring-data manages to fill them with default values if absent.

You are right, that it makes more sense to give flexibility to the user to decide.
The change, will be available for the next release: v1.3.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants