hugo-theme-relearn/exampleSite/content/shortcodes/openapi/_index.en.md
2023-06-05 23:20:37 +02:00

1.7 KiB

description title
UI for your OpenAPI / Swagger specifications OpenAPI

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

{{% notice note %}} This only works in modern browsers. {{% /notice %}}

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
  "context" .
  "src" "https://petstore3.openapi.io/api/v3/openapi.json"
)}}

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

Parameter

Name Default Notes
src <empty> The URL to the OpenAPI specification file. This can be relative to the URL of your page if it is a leaf or branch bundle.

{{% 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]({{% relref "basics/configuration/#activate-print-support" %}}) 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" >}}