Paging and sorting using Open Api 3.0 in Spring boot project?

290 Views Asked by At

Im very new to Spring boot. I'm doing a project in Spring boot 3.2.5 with Maven. I have used Springdoc Open Api 3.0 in the project. I have implemented paging and sorting. Could you help me customize the default size and sorting criteria in the same? Do I need to configure?

1

There are 1 best solutions below

0
On

I found the answer, and it was pretty easy. You just need to add @PageableDefault as shown below. You may even change the default page number using 'page = "value" '.

public Entity findAll(@ParameterObject @PageableDefault(size = 5, sort = "name")Pageable pageable)