【问题标题】:How do I refer between different APIs in SwaggerHub?如何在 SwaggerHub 中的不同 API 之间进行引用?
【发布时间】:2018-12-14 18:59:10
【问题描述】:

我正在使用 SwaggerHub 和 OpenAPI 3.0.0。我在 SwaggerHub 中有两个 API。

第一个有以下访问链接: https://app.swaggerhub.com/apis/myapipath/1.0.0 并包含一个名为 components/schemas/ApiOffer 的定义。

在第二个 API 中,我希望属性 offer 成为该定义的 $ref。我用:

components:
  schemas:
    Offerers:
      type: object
      required:
        - offererId
        - overview
      properties:
        offererId:
          $ref: '#/components/schemas/OfferersId'
        overview:
          $ref: '#/components/schemas/OfferersOverview'
        offer:
          $ref: 'https://app.swaggerhub.com/apis/myapipath/1.0.0#/components/schemas/ApiOffer'

但得到以下错误:

“无法解析引用,因为:无法解析指针: /components/schemas/ApiOffer 在文档中不存在"

即使/components/schemas/ApiOffer 定义存在。

如何更正我的引用以使其指向其他 API?

【问题讨论】:

    标签: swagger openapi swaggerhub


    【解决方案1】:

    对 SwaggerHub 定义的引用必须使用主机名 API.swaggerhub.com 而不是 APP.swaggerhub.com

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-01
      • 1970-01-01
      • 2019-04-10
      • 1970-01-01
      • 1970-01-01
      • 2016-07-08
      相关资源
      最近更新 更多