Java Flux contains_java - 用于Spring-Webflux / Mono或Flux对象的OpenAPI CodeGen作为返回 - 堆栈内存溢出...

轩辕经国
2023-12-01

OpenApi Codegen的最新版本(及其Maven插件)/应该能够使用Webflux / Reative返回对象(例如Mono或Flux对象)自动生成Spring Maven的接口。 但是,我认为它无法正常工作。 这些是我pom.xml的摘录:

io.swagger

swagger-codegen-maven-plugin

${swagger.codegen.version}

authentication-api

generate

src/main/resources/swagger/authentication.yaml

spring

src/main/java

spring-boot

true

java8

true

${project.groupId}.api

${project.groupId}.model

true

这些是来自authentication.yaml和生成的接口的摘录

authentication.yaml

paths:

/dotcmsAuthentication:

get:

tags:

- authentication

- dotCMS

description: Returns dotCMS json with JWT Token.

operationId: getDotcmsAuthentication

produces:

- application/json

consumes:

- application/json

parameters:

- name: DotcmsAuthentication

in: header

required: true

schema:

type: string

example: '{"user":"username", "password":"password"}'

responses:

'200':

description: Successful authentication

schema:

$ref: '#/definitions/UserAuthentication'

'401':

description: Malformed authentication header

content:

application/json:

schema:

$ref: '#/components/schemas/MalformedAuthenticationHeaderError'

'400':

description: BAD_REQUEST error

content:

application/json:

schema:

$ref: '#/components/schemas/RequestError'

和自动生成的身份验证界面:

@ApiOperation(value = "", nickname = "getDotcmsAuthentication", notes = "Returns dotCMS json with JWT Token.", response = UserAuthentication.class, tags={ "authentication","dotCMS", })

@ApiResponses(value = {

@ApiResponse(code = 200, message = "Successful authentication", response = UserAuthentication.class),

@ApiResponse(code = 400, message = "BAD_REQUEST error"),

@ApiResponse(code = 401, message = "Malformed authentication header") })

@RequestMapping(value = "/dotcmsAuthentication",

produces = { "application/json" },

consumes = { "application/json" },

method = RequestMethod.GET)

default ResponseEntity getDotcmsAuthentication(@ApiParam(value = "" ,required=true) @RequestHeader(value="DotcmsAuthentication", required=true) String dotcmsAuthentication) {

if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {

if (getAcceptHeader().get().contains("application/json")) {

try {

return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"jwtToken\" : \"jwtToken\"}", UserAuthentication.class), HttpStatus.NOT_IMPLEMENTED);

} catch (IOException e) {

log.error("Couldn't serialize response for content type application/json", e);

return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);

}

}

} else {

log.warn("ObjectMapper or HttpServletRequest not configured in default AuthenticationApi interface so no example is generated");

}

return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);

}

现在,主要问题是:我如何获取openapi-codegen来生成MONO和Flux对象而不是这些ResponseEntity对象?

如果您需要其他任何帮助的细节,请告诉我,我会提供。 谢谢。

 类似资料: