【问题标题】:Generated sources with API-First development in jhipster在 jhipster 中使用 API-First 开发生成的源代码
【发布时间】:2020-01-08 00:45:26
【问题描述】:

我正在尝试使用 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 文件夹下生成,以供我的实现扩展。 我的理解正确吗?我应该手动将它们复制到我的源文件夹吗? 谢谢。

【问题讨论】:

  • 是的,如果您想编辑这些,您可以手动复制它们。插件是这样设置的,所以事实的来源是 openapi 代码,你扩展生成的接口。

标签: java jhipster openapi-generator


【解决方案1】:

默认输出路径是${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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-24
    • 2012-12-24
    • 2014-11-19
    • 1970-01-01
    • 2014-05-17
    • 1970-01-01
    • 1970-01-01
    • 2015-05-07
    相关资源
    最近更新 更多