【问题标题】:Openapi YAML wrong, cannot generate client-stubsOpenapi YAML 错误,无法生成客户端存根
【发布时间】:2020-03-27 16:49:23
【问题描述】:

我将 Quarkus 评估为后端,由 Angular 前端访问。 我想使用 Quarkus 通过http://localhost:8080/openapi 提供的openapi 数据, 并通过 openapi-generator 工具生成 typescript-angular 客户端存根。

我使用 Quarkus Openapi 指南作为第一步:https://quarkus.io/guides/openapi-swaggerui 但是在运行未修改的示例并通过 http://localhost:8080/openapi 检索 Openapi YAML 数据后,我注意到生成的数据是错误的,并且由于 stackoverflow 错误,openapi 生成器无法生成客户端。

问题:SetFruit-Definition(最后一行)的 Openapi-data 中的自引用:

openapi: 3.0.1
info:
  title: Generated API
  version: "1.0"
paths:
  /fruits:
    get:
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SetFruit'
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Fruit'
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SetFruit'
    delete:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Fruit'
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SetFruit'
components:
  schemas:
    Fruit:
      type: object
      properties:
        description:
          type: string
        name:
          type: string
    SetFruit:
      $ref: '#/components/schemas/SetFruit'

这是一个已知问题,还是我这边有一些误解。 有没有办法解决这个问题?

非常感谢!

【问题讨论】:

标签: quarkus smallrye


【解决方案1】:

绝对不应该生成自引用定义!您能否在这里提出一个问题:

https://github.com/smallrye/smallrye-open-api/issues

该库是 Quarkus 支持此功能背后的实现。如果您可以包含一个非常有帮助的复制器项目。或者至少给我们一些关于FruitSetFruit java 类的信息。

【讨论】:

【解决方案2】:

这个问题将在下周发布的 Quarkus 1.3.0.CR1 中解决。

【讨论】:

    猜你喜欢
    • 2023-01-10
    • 2022-10-05
    • 1970-01-01
    • 1970-01-01
    • 2021-08-08
    • 1970-01-01
    • 2022-11-03
    • 1970-01-01
    • 2013-01-02
    相关资源
    最近更新 更多