我使用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)