【发布时间】:2022-01-17 20:18:39
【问题描述】:
当用户使用 Pageable 进行查询时,我有一个自定义页面要返回。这个页面有一个通用参数,我想在我的 Swagger 文档中指定它。 这是当前的结果:
elements 是我的泛型类型的实例列表。
我实际拥有的签名功能:
@CustomPageableAsQueryParam
@Operation(summary = "", operationId = "get_all_version")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Versions found an returned",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = CustomPage.class)))
})
@GetMapping(path = "/versions", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<CustomPage<ReducedVersion>> getVersions(
@ParameterObject
@PageableDefault(sort = {"releaseTime"}, direction = Sort.Direction.DESC) Pageable pageable,
@Parameter(description = "Version type to filter the list") @RequestParam(required = false) VersionType type) {
理想情况下,我可以使用@Schema(implementation = CustomPage<ReducedVersion>.class),但在 Java 中这是不可能的。
Spring 是否提供了克服此限制的方法?
感谢您以后的回答!
【问题讨论】:
标签: java swagger spring-restdocs springdoc