假设我有一个用枚举模式定义的参数:
paths:
/echo:
get:
parameters:
- name: someEnum
in: query
required: true
schema:
type: string
enum: [A, B, C]
responses:
200:
description: Success
content:
text/plain:
schema:
type: string
Swagger codegen 为语言生成以下 Java 接口spring:
@ApiOperation(value = "", nickname = "echoGet", notes = "", response = String.class, tags={ })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = String.class) })
@RequestMapping(value = "/echo",
produces = { "text/plain" },
method = RequestMethod.GET)
default ResponseEntity<String> echoGet(@NotNull @ApiParam(value = "", required = true, allowableValues = "A, B, C") @Valid @RequestParam(value = "someEnum", required = true) String someEnum) {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
} else {
log.warn("ObjectMapper or HttpServletRequest not configured in default EchoApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
someEnum生成接口的类型是字符串。如何用具有“A”、“B”、“C”值的 Java 枚举替换它?
绝地无双
LEATH
相关分类