Search code examples
swaggeropenapiswaggerhub

Define OpenAPI domains locally and avoid publishing on SwaggerHub


I'm tinkering with OpenAPI and I would like to make my components definition available in a separate file. I understand that this is achieved through domains created on SwaggerHub. My problem is that I am at the stage when I am still playing around and would love to avoid publishing stuff on a third-party site.

Is there a way to reference a domain with $ref a local file (and avoid referencing a file on SwaggerHub.com)?


Solution

  • Just to close the loop, I'll answer my own question here. The person who answered my question above did help put me on the right track, but I can't honestly say that he answered my question.

    I guess that what confused me initially was a (all things considered good) Swagger tutorial on Linkedin that explained how to do Local References, and then jumped to explaining SwaggerHub "domains" as (what appeared as the only way to) the path to reusable schema definitions.

    It turns out that the answer to my question was as simple as:

    $ref: './my-schemas.yaml#/components/schemas/myGoodStuff'
    

    This is referred to as Remote Reference in the https://swagger.io/docs/specification/using-ref/.