Created
January 13, 2021 10:13
-
-
Save susimsek/08263c43d6a17c61b53ed0aed8787d14 to your computer and use it in GitHub Desktop.
Spring boot Swagger Pagination
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @EnableSwagger2 | |
| @Configuration | |
| public class SwaggerConfig { | |
| @Bean | |
| public Docket docket() { | |
| return new Docket(DocumentationType.SWAGGER_2) | |
| .select() | |
| .paths(PathSelectors.any()) | |
| .build() | |
| .apiInfo(metaData()) | |
| .directModelSubstitute(Pageable.class,SwaggerPageable.class) | |
| .useDefaultResponseMessages(false); | |
| } | |
| private ApiInfo metaData() { | |
| return new ApiInfoBuilder() | |
| .title("DAS REST API") | |
| .description("\"Provides access to the core features of Digital Archiving System Rest Api.\"") | |
| .version("1.0.0") | |
| .build(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Data | |
| public class SwaggerPageable { | |
| @ApiModelProperty(value = "Number of records per page", | |
| dataType = "int", | |
| example = "10" | |
| ) | |
| private String size; | |
| @ApiModelProperty(value = "Results page you want to retrieve (0..N)", | |
| dataType = "int", | |
| example = "0" | |
| ) | |
| private String page; | |
| @ApiModelProperty( | |
| value = "Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", | |
| dataType = "string" | |
| ) | |
| private String sort; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment