我希望通过查看和https://techsparx.com/software-development/openapi/spring-boot-rest-api-docs.html来开发https://www.dariawan.com/tutorials/spring/documenting-spring-boot-rest-api-springdoc-openapi-3/ Spring+ OpenAPI 3示例。在本例中,我希望通过添加springdoc-openapi-ui获得的Swagger传递分页细节。
为了支持自定义分页,我需要做哪些Spring配置。?
发布于 2020-01-23 13:52:51
在方法上添加@PageableAsQueryParam注释,并将springdoc data-rest作为依赖项添加
发布于 2021-04-05 19:15:09
它们不止一个最简单和最快的可能性--如果只想启用的支持,就可以使用以下方法启用它:
SpringDocUtils.getConfig().replaceWithClass(org.springframework.data.domain.Pageable.class,
org.springdoc.core.converters.models.Pageable.class);或者,使用Pageable类型的项目可以添加折叠依赖项和springdoc ui依赖项。这种依赖关系还支持spring rest类型:@RepositoryRestResource和QuerydslPredicate注释。
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-data-rest</artifactId>
<version>1.5.6</version>
</dependency>并在控制器方法的Pageable对象上添加@ParameterObject。
@GetMapping("/books")
public ResponseEntity<List<BookDTO>> getBooks(@ParameterObject Pageable pageable)发布于 2022-03-29 09:19:59
“自springdoc v1.6.0以来,对springdoc公域可访问性的支持是现成的。为此,您必须将@ParameterObject注释与Pageable类型结合起来。”- 来源。
假设您使用的是springdoc v1.6.0或grater,您可以这样做:
@GetMapping("/foo")
public Page<Foo> getFoo(@ParameterObject Pageable pageable) {
// do something
}https://stackoverflow.com/questions/59827985
复制相似问题