hugo-theme-relearn/exampleSite/content/shortcodes/openapi/_index.en.md
Sören Weber b0c38a6257
openapi: adjust to Hugo's build-in link render hook #860
- resolve render hook destination with leading ./
- configurable message for unresolved local adresses
2024-05-28 22:17:36 +02:00

1.6 KiB

description title
UI for your OpenAPI / Swagger specifications OpenAPI

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

Usage

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

{{< tabs groupid="shortcode-parameter">}} {{% tab title="shortcode" %}}

{{</* openapi src="https://petstore3.openapi.io/api/v3/openapi.json" */>}}

{{% /tab %}} {{% tab title="partial" %}}

{{ partial "shortcodes/openapi.html" (dict
  "page" .
  "src"  "https://petstore3.openapi.io/api/v3/openapi.json"
)}}

{{% /tab %}} {{< /tabs >}}

Parameter

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.

{{% notice note %}} 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. {{% /notice %}}

Example

Using Local File

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

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