hugo-theme-relearn/exampleSite/content/shortcodes/swagger/_index.en.md
2022-03-28 21:43:09 +02:00

1.3 KiB

description title
Adds UI for your Swagger / OpenAPI Specifications Swagger

This shortcode uses the RapiDoc library to display your OpenAPI Specifications.

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

Configuration

Swagger is configured with default settings. You can customize Swagger's default settings for all of your files thru a JSON object in your config.toml or override these settings per page thru your pages frontmatter.

The JSON object of your config.toml / frontmatter is forwarded into Swagger's initialization. At the moment, only the theme setting is supported.

The theme setting can also be set by your used color variant. This will be the sitewide default and can - again - be overridden by your settings in config.toml or frontmatter.

Example

[params]
  swaggerInitialize = "{ \"theme\": \"dark\" }"

Usage

Just insert give the URL to your OpenAPI Specification like this:

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

If your page is a leaf or branch bundle, you can also use relative URLs:

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

The src parameter is mandatory and can be either an absolute or a relative URL.

Example

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