Search code examples
swaggeropenapiswaggerhub

How do I refer between different APIs in SwaggerHub?


I am working with SwaggerHub and OpenAPI 3.0.0. I have two APIs in SwaggerHub.

The first has got following access link: https://app.swaggerhub.com/apis/myapipath/1.0.0 and contains a definition named components/schemas/ApiOffer.

In the second API, I want the property offer to be a $ref to that definition. I use:

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'

but get the following error:

"Could not resolve reference because of: Could not resolve pointer: /components/schemas/ApiOffer does not exist in document"

even though the /components/schemas/ApiOffer definition exists.

How do I correct my reference so that it points to the other API?


Solution

  • References to SwaggerHub definitions must use the hostname API.swaggerhub.com instead of APP.swaggerhub.com.