How does one refer to an API on Swaggerhub within another API?

410 Views Asked by At

When referencing a domain, you would use the following to get the CommonSchema model from the CommonDomain domain

$ref: 'https://api.swaggerhub.com/domains/CompanyName/CommonDomain/1.0.0#/components/schemas/CommonSchema'

How can you make a reference to another existing api? This is being done from another API within Swaggerhub. When I attempt to do something like this to get the SomeSchema model

$ref: 'https://api.swaggerhub.com/apis/CompanyName/SomeApi/1.0.0#/components/schemas/SomeSchema'

I get an error saying that it Could not resolve reference: 404 Unknown Domain CompanyName/SomeApi:1.0.0

This would be legal for swagger codegen to generate from. Is this just a limitation of swaggerhub? If not, how does one go about doing this properly?

1

There are 1 best solutions below

0
On

This functionality does not exist in SwaggerHub. You can only reference an object from a domain file in SwaggerHub, not an API file.

This is how I think about it:

Any object in a domain file can be referenced by any other file (within the same org).

Objects with an API file can only be referenced within the same file.