OpenAPI CodeGen for Spring-Webflux / Mono 或 Flux 对象作为返回

J. *_*fer 6 java mono spring openapi reactive

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

    <plugin>
        <groupId>io.swagger</groupId>
        <artifactId>swagger-codegen-maven-plugin</artifactId>
        <version>${swagger.codegen.version}</version>
        <executions>
        <!-- AUTHENTICATION-API -->
            <execution>
              <id>authentication-api</id>
              <goals>
                <goal>generate</goal>
              </goals>
              <configuration>
                <inputSpec>src/main/resources/swagger/authentication.yaml</inputSpec>
                <language>spring</language>
                <configOptions>
                  <sourceFolder>src/main/java</sourceFolder>
                    <library>spring-boot</library>
                    <!-- <async>true</async> -->
                    <reactive>true</reactive>
                    <dateLibrary>java8</dateLibrary>
                    <useTags>true</useTags>
                    <apiPackage>${project.groupId}.api</apiPackage>
                    <modelPackage>${project.groupId}.model</modelPackage>
                    <interfaceOnly>true</interfaceOnly>
                </configOptions>
              </configuration>
            </execution>
         </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

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

身份验证.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'
Run Code Online (Sandbox Code Playgroud)

并自动生成身份验证接口:

@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<UserAuthentication> 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);
}
Run Code Online (Sandbox Code Playgroud)

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

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