githubopenapiswagger-editor

Best way how to publish OpenAPI document on GitHub (readme.md)?


I have a project hosted on GitHub. To document the API I am using the OpenAPI spec. Now I want to add a link on readme.md (on GitHub) that refers my visitors to the OpenAPI document for good user experience.

Far as I see I have two solutions:

Both approaches are working, but they both open with an editor on left side that shows the content of YAML file and is, IMHO, wasting a significant screen space. Not really what I want. Is there an option to display the OpenAPI document without editor opened? Just similiar what is done for https://petstore.swagger.io/ which comes without editor opened.

Or ... is there maybe an option available to display the OpenAPI document on GitHub directly?

Thanks, Christoph


Solution

  • If you use SwaggerHub, replace /apis/ with /apis-docs/ in the URL to view just the API docs without the editor part. For example:

    https://app.swaggerhub.com/apis-docs/swagger-hub/registry-api/1.0.47


    Or if your OpenAPI definition is hosted elsewhere (e.g. on GitHub), you can use
    https://petstore.swagger.io/?url=https://path/to/file.yaml

    to load it into the public Swagger UI demo. Swagger UI renders API docs without the editor part.