我已经浏览了文档:https ://springdoc.github.io/springdoc-openapi-demos/faq.html#how-can-i-ignore-some-field-of-model- ,但是文档不是很清楚,我有Spring Boot REST HATEOAS实现项目并使用Open API 3 规范而不是 Swagger。
我已经为每个端点实现了分页,但是我的行业标准如何期望内容作为复数内容。但由于这是 Pageable API 的一部分,我无法覆盖它,而是希望禁用它。有什么建议我们该怎么做?
PageEmployeeOut:
type: object
properties:
totalElements:
type: integer
format: int64
totalPages:
type: integer
format: int32
size:
type: integer
format: int32
content:
type: array
items:
$ref: '#/components/schemas/EmployeeOut'
number:
type: integer
format: int32
sort:
$ref: '#/components/schemas/Sort'
numberOfElements:
type: integer
format: int32
first:
type: boolean
pageable:
$ref: '#/components/schemas/Pageable'
last:
type: boolean
empty:
type: boolean
就像在 Springfox Swagger 中一样,我们可以像下面那样做,在Open API 3 (springdoc-openui)中它的等价物是什么 ?
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.boot")))
.apis(RequestHandlerSelectors.basePackage("com.example"))
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo())
.useDefaultResponseMessages(false)
.ignoredParameterTypes(Pageable.class);
}
这是我的终点
public ResponseEntity<Page<EmployeeDto>> findEmployees(@Parameter(hidden=true) Pageable pageable) {
Page<EmployeeDto> page = employeeService.findAllEmployees(page_params, pageable);
return new ResponseEntity<>(page, HttpStatus.OK);
}