feat(config): 添加PageableOpenApiCustomizer配置类
新增PageableOpenApiCustomizer配置类,用于自定义OpenAPI的分页参数,确保size参数的最小值为0
This commit is contained in:
parent
f6fcf714c5
commit
1abc943e01
@ -0,0 +1,29 @@
|
||||
package com.vxnet.pms.config;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.springdoc.core.customizers.OpenApiCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class PageableOpenApiCustomizer {
|
||||
|
||||
@Bean
|
||||
public OpenApiCustomizer customizePageableOpenApi() {
|
||||
return openApi ->
|
||||
openApi
|
||||
.getPaths()
|
||||
.values()
|
||||
.stream()
|
||||
.flatMap(pathItem -> pathItem.readOperations().stream())
|
||||
.forEach(operation -> {
|
||||
if (operation.getParameters() != null) {
|
||||
operation
|
||||
.getParameters()
|
||||
.stream()
|
||||
.filter(parameter -> parameter.getName().equals("size"))
|
||||
.forEach(parameter -> parameter.getSchema().setMinimum(BigDecimal.ZERO));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user