【问题标题】:How To ignore Endpoints from openapi.yaml in generation with openapi-generator-maven-plugin/如何使用 openapi-generator-maven-plugin/ 在生成时忽略来自 openapi.yaml 的端点
【发布时间】:2022-07-15 17:09:50
【问题描述】:

yaml 和 openapi-generator-maven-plugin 正确地从它生成 Spring Boot 控制器接口。一切正常。但是现在我们想用我们自己的接口覆盖生成的接口之一。我们如何从这一代中排除某个端点?

例子:

  paths:
  /currencies:
    get:
      tags:
        - DomainData
      summary: Lists all valid currencies available.
      operationId: "getCurrencies"
      parameters:
        - $ref: '#/components/parameters/AcceptLanguage'
      responses:
        "200":
          description: "OK"
          content:
            application/json:
              schema:
                type: string
                additionalProperties:
                  type: string
        '401':
          $ref: '#/components/responses/Unauthorized'
        '5XX':
          $ref: '#/components/responses/Unexpected'

  /languages:
    get:
      tags:
        - DomainData
      summary: Lists all valid languages available.
      operationId: "getLanguages"
      parameters:
        - $ref: '#/components/parameters/AcceptLanguage'
      responses:
        "200":
          description: "OK"
          content:
            application/json:
              schema:
                type: string
                additionalProperties:
                  type: string
        '401':
          $ref: '#/components/responses/Unauthorized'
        '5XX':
          $ref: '#/components/responses/Unexpected'

这是 openapi.yaml 的一部分,我们不想为 /languages 而生成其他所有内容。

【问题讨论】:

  • 你不能从 open-api 规范中删除它吗?
  • @ShivajiPote 不,我们从中产生了招摇并希望将其保留在那里。
  • 但是如果没有 API 实现,这种招摇会有用吗?
  • 是的,它非常有用。问题是网关从另一台服务器获取该端点,但应该大摇大摆地看到它。导致它寻找 API 用户,因为它是一个 api。

标签: spring-boot openapi-generator openapi-generator-maven-plugin


【解决方案1】:

我找到了一个我们使用 .openapi-generator-ignore 的解决方案 并将其链接到 openapi 生成器的 pom 选项中。

在 .openapi-generator-ignore 中,我们使用了从忽略文件位置到不存在且我们不想生成的文件的完整相对路径。

target/generated-sources/v1/src/main/java/ch/allianz/dsp/bff/kp/generated/api/languageApi.java

【讨论】:

    猜你喜欢
    • 2021-08-08
    • 1970-01-01
    • 2022-07-23
    • 2020-10-26
    • 2022-09-30
    • 1970-01-01
    • 1970-01-01
    • 2022-08-05
    • 2023-03-04
    相关资源
    最近更新 更多