我正在尝试在 swagger-maven-plugin 生成的 OpenAPI 文件中列出对象查询参数。我有以下端点,其中包含两个对象RecargaCupoFilter
,并且Pageable
每个对象都有自己的参数。
@GetMapping(value = "/wallet/recharge", produces = {"application/json; charset=UTF-8"})
@ApiOperation(value = "Allow to query recharge history", produces = "application/json")
@PreAuthorize("isAuthenticated() and (#filter.username == authentication.name or hasAnyRole('ROLE_COORDINADOR_CUPO', 'ROLE_ADMINISTRADOR'))")
@ApiPageable
public ResponseEntity<List<OperacionDTO>> consultarRecargas(RecargaCupoFilter filter, Pageable pageable) {
pageable = PaginationUtil.ensurePageMaxSize(pageable);
Page<OperacionDTO> page = cupoService.consultarRecargaCupo(filter, pageable);
HttpHeaders headers = PaginationUtil
.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page);
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
当我尝试生成 OpenAPI 文件时,我得到以下信息:
/api/wallet/recharge:
get:
summary: "Allow to query recharge history"
description: ""
operationId: "BilleteraResource_consultarRecargas_GET"
produces:
- "application/json; charset=UTF-8"
parameters:
- name: "filter"
in: "query"
required: true
- name: "sort"
in: "query"
description: "Criterios de ordenamiento, con formato: propiedad(,asc|desc).\
\ El orden por defecto es ascendente. Se soportan múltiples criterios de\
\ ordenamiento."
required: false
type: "array"
items:
type: "string"
collectionFormat: "multi"
responses:
200:
description: "successful operation"
schema:
type: "array"
items:
$ref: "#/definitions/OperacionDTO"
我希望有类似 SpringFox 生成的文件。
/api/wallet/recharge:
get:
tags:
- billetera-resource
summary: Allow to query recharge historyo
operationId: consultarRecargasUsingGET
produces:
- application/json;charset=UTF-8
- application/json
parameters:
- name: offset
in: query
required: false
type: integer
format: int64
- name: pageNumber
in: query
required: false
type: integer
format: int32
- name: pageSize
in: query
required: false
type: integer
format: int32
PS:我使用 swagger-maven-plugin 因为它在 Maven 构建阶段生成 OpenAPI 文件而不执行应用程序。