Springdoc-openapi: Pageable required

Created on 13 Apr 2020  路  5Comments  路  Source: springdoc/springdoc-openapi

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

Most helpful comment

@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.

All 5 comments

Hi @kfirfer,

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

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

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

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

@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.

Was this page helpful?
0 / 5 - 0 ratings