Springdoc Data REST 忽略覆盖 Pageable 参数名称

Springdoc Data REST ignore overwrite Pageable parameters name

在我的 application.properties 中,我已经覆盖了 Pageable 参数的名称:

spring.data.web.pageable.page-parameter=offset
spring.data.web.pageable.size-parameter=limit

但是当我去SwaggerUI查看我的Swagger文档时,没有使用新的名称参数:

这是我的函数的签名:

@PageableAsQueryParam
    @Operation(summary = "")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "",
                    content = @Content(mediaType = "application/json", schema = @Schema(implementation = CustomPage.class))),
            @ApiResponse(responseCode = "404", description = "", content = @Content)
    })
    @GetMapping(path = "/{version}/foo", produces = MediaType.APPLICATION_JSON_VALUE)
    @Override
    public ResponseEntity<CustomPage<ReducedAsset>> getAll(@ParameterObject Pageable pageable,
                                                           @Parameter(description = "Version from which to get the list")
                                                           @PathVariable String version)

如何将新名称绑定到文档?我可以更改默认描述吗?

感谢您的回答!

最简单且侵入性较小的方法可能是:

package com.example.springdocdatarest;

import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Schema;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Parameter(in = ParameterIn.QUERY,
     description = "Zero-based page index (0..N)",
     name = "offset", // !
     schema = @Schema(type = "integer", defaultValue = "0"))
@Parameter(in = ParameterIn.QUERY,
     description = "The size of the page to be returned",
     name = "limit", // !
     schema = @Schema(type = "integer", defaultValue = "20"))
@Parameter(in = ParameterIn.QUERY,
     description = "Sorting criteria in the format: property(,asc|desc). "
    + "Default sort order is ascending. " + "Multiple sort criteria are supported.",
     name = "sort",
     array = @ArraySchema(schema = @Schema(type = "string")))
public @interface MyPageableAsQueryParam {

}
  1. 正在从 https://github.com/springdoc/springdoc-openapi/blob/master/springdoc-openapi-common/src/main/java/org/springdoc/core/converters/models/PageableAsQueryParam.java
  2. 复制
  3. 替换为我们想要的值。 (还有描述;)

并使用它:

@com.example.springdocdatarest.MyPageableAsQueryParam
@Operation(summary = "") // ...
@GetMapping ...

测试(切换版本和Pageable参数(order;)):

备注

还有:

spring.data.rest.page-param-name=foo
spring.data.rest.limit-param-name=bar
spring.data.rest...

个“这些”属性。