相关疑难解决方法(0)

Spring Pageable接口的Swagger文档

我使用Spring Boot开发了一个微服务.REST API的文档是使用Swagger完成的.一些REST资源利用Spring概念免费提供分页.以下是一个例子:

@RequestMapping(value = "/buckets", method = GET)
public PagedResources list(Pageable pageable, PagedResourcesAssembler assembler) {
    return bucketService.listBuckets(pageable, assembler);
}
Run Code Online (Sandbox Code Playgroud)

如果我打开Swagger页面,则可以使用以下表单:

在此输入图像描述

我遇到的问题是使用content-type application/json检测pageable参数,我不知道如何传递值来更改页面大小.似乎忽略了所有值.

是否可以将查询参数作为JSON对象传递?或者是否可以配置Swagger为Pageable接口包含的getter生成独立的查询参数字段?

请注意我使用带有Gradle的Springfox:

compile 'io.springfox:springfox-spring-web:2.3.1'
compile 'io.springfox:springfox-swagger2:2.3.1'
compile 'io.springfox:springfox-swagger-ui:2.3.1'
Run Code Online (Sandbox Code Playgroud)

rest spring json swagger

21
推荐指数
7
解决办法
1万
查看次数

标签 统计

json ×1

rest ×1

spring ×1

swagger ×1