2

我正在尝试使用 openapi 生成器在 jhipster 中生成一个新服务,但是生成的源是在 builddirectory (目标)上创建的,因此对于覆盖这些源并添加我的逻辑没有用。我应该在我的过程中改变什么?

我创建了招摇代码,并按照 jhipster 文档中的建议运行生成源:https ://www.jhipster.tech/doing-api-first-development/

openapi: '3.0.1'
info:
  title: 'Example'
  version: 0.0.1
servers:
  - url: http://localhost:8080
    description: Development server
  - url: https://localhost:8080
    description: Development server with TLS Profile
paths:
  /assessments/{reference}:
    get:
      summary: active assessments for a given reference
      operationId: getAssessmentsByDevice
      description: |
        By passing a unique identifier reference, you can get active assessments for that device
      parameters:
        - in: path
          name: reference
          description: unique device identifier
          required: true
          schema:
            type: string
      responses:
        '200':
          description: active assessments for a device
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
        '400':
          description: bad input parameter
        '404':
          description: reference not found

并运行发电机:

[INFO] OpenAPI Generator: spring (server)
[INFO] Generator 'spring' is considered stable.
[INFO] ----------------------------------
[INFO] Environment variable JAVA_POST_PROCESS_FILE not defined so the Java code may not be properly formatted. To define it, try 'export JAVA_POST_PROCESS_FILE="/usr/local/bin/clang-format -i"' (Linux/Mac)
[INFO] NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).
[INFO] Invoker Package Name, originally not set, is now derived from api package name: com.hcb.happyratingmodel.web
[INFO] Processing operation getAssessmentsByDevice
[INFO] writing file C:\Users\cduquemarcos\Documents\Documentation\Projects\Personal\example\target\generated-sources\openapi\src\main\java\com\hcb\example\web\api\AssessmentsApiController.java
[INFO] writing file C:\Users\cduquemarcos\Documents\Documentation\Projects\Personal\example\target\generated-sources\openapi\src\main\java\com\hcb\example\web\api\AssessmentsApi.java
[INFO] writing file C:\Users\cduquemarcos\Documents\Documentation\Projects\Personal\example\target\generated-sources\openapi\src\main\java\com\hcb\example\web\api\AssessmentsApiDelegate.java
[INFO] writing file C:\Users\cduquemarcos\Documents\Documentation\Projects\Personal\example\target\generated-sources\openapi\src/main/java\com\hcb\example\web\api\ApiUtil.java
[INFO] writing file C:\Users\cduquemarcos\Documents\Documentation\Projects\Personal\example\target\generated-sources\openapi\.openapi-generator\VERSION
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] -----------------------------------------------------------------------

我期待这些类将在 SRC 文件夹下生成,以供我的实现扩展。我的理解正确吗?我应该手动将它们复制到我的源文件夹吗?谢谢。

4

1 回答 1

0

默认输出路径是${project.build.directory}/generated-sources/openapi您可以通过在配置设置中使用output属性更改它或通过openapi.generator.maven.plugin.output属性对其进行全局设置来修改它。

更多详细信息和其他配置选项:https ://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-maven-plugin

于 2021-04-14T15:56:07.963 回答