The openapi shortcode uses the Swagger UI library to display your OpenAPI / Swagger specifications.


While the examples are using shortcodes with named parameter you are free to also call this shortcode from your own partials.

{{< openapi src="" >}}
{{ partial "shortcodes/openapi.html" (dict
  "page" .
  "src"  ""


Name Default Notes
src <empty> The path to the to the OpenAPI specification resource or URL to be used. Resource paths adhere to Hugo’s logical path.

If you want to print out (or generate a PDF) from your OpenAPI documentation, don’t initiate printing directly from the page because the elements are optimized for interactive usage in a browser.

Instead, open the print preview in your browser and initiate printing from that page. This page is optimized for reading and expands most of the available sections.


Using Local File

{{< openapi src="petstore.json" >}}