question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@springdoc Great contribution! But we're still having issues with `Pageable`.

See original GitHub issue

@springdoc Great contribution! But we’re still having issues with Pageable.

Version: 1.2.17

The pageable-parameters are passed as offset=0&pageNumber=0&pageSize=0&sort=sorted,true,unsorted,true,empty,true&paged=true&unpaged=true

image

_Originally posted by @NicklasWallgren in https://github.com/springdoc/springdoc-openapi/issues/177#issuecomment-563992434_

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
AnnaKarlssoncommented, Dec 12, 2019

Created annotation to not have 15 lines of code in every pageable request. Hope it helps someone 😃


@Target({METHOD, ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Operation(parameters = {
        @Parameter(in = ParameterIn.QUERY
                , description = "Page you want to retrieve (0..N)"
                , name = "page"
                , content = @Content(schema = @Schema(type = "integer", defaultValue = "0"))),
        @Parameter(in = ParameterIn.QUERY
                , description = "Number of records per page."
                , name = "size"
                , content = @Content(schema = @Schema(type = "integer", defaultValue = "20"))),
        @Parameter(in = ParameterIn.QUERY
                , description = "Sorting criteria in the format: property(,asc|desc). "
                + "Default sort order is ascending. " + "Multiple sort criteria are supported."
                , name = "sort"
                , content = @Content(array = @ArraySchema(schema = @Schema(type = "string"))))
})
public @interface PageableOperation {

    @AliasFor(annotation = Operation.class)
    String summary() default "";

    //... the other methods of Operation you use

}
3reactions
GrmpfNarfcommented, Dec 11, 2019

Hi, as a Workaround i have hidden the Pageable param and add the parameters via annotation manually.

@GetMapping
@Operation(
    parameters = {
        @Parameter(in = ParameterIn.QUERY
                            , description = "Page you want to retrieve (0..N)"
                            , name = "page"
                            , content = @Content(schema = @Schema(type = "integer", defaultValue = "0"))),
        @Parameter(in = ParameterIn.QUERY
                            , description = "Number of records per page."
                            , name = "size"
                            , content = @Content(schema = @Schema(type = "integer", defaultValue = "20"))),
        @Parameter(in = ParameterIn.QUERY
                            , description = "Sorting criteria in the format: property(,asc|desc). "
                            + "Default sort order is ascending. " + "Multiple sort criteria are supported."
                            , name = "sort"
                            , content = @Content(array = @ArraySchema(schema = @Schema(type = "string"))))
            })
public PagedModel<EntityModel<..>> getIspContractsByContractSearch(@PageableDefault @Parameter(hidden = true) Pageable pageable) {
     ...
}      
Read more comments on GitHub >

github_iconTop Results From Across the Web

Springdoc Data REST ignore overwrite Pageable parameters ...
In my application.properties, I have overwritten ...
Read more >
F.A.Q - Springdoc-openapi
Another solution, is to configure Pageable manually: you will have to declare the explicit mapping of Pageable fields as Query Params and add...
Read more >
Spring Data REST Reference Guide
If the repository is a paging repository we include the pagination links if necessary and additional page metadata. Methods used for invocation.
Read more >
Springfox Reference Documentation - GitHub Pages
Springfox works by examining an application, once, at runtime to infer API semantics based on spring configurations, class structure and various ...
Read more >
'Code First' API Documentation with Springdoc and Spring Boot
All the annotations that we will be using are from Swagger. Springdoc wraps Swagger and offers us a single dependency which we can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found