swagger: support leaf and page bundles #226

This commit is contained in:
Sören Weber 2022-03-27 23:08:29 +02:00
parent 02cb15e0f4
commit dd2233d93b
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
4 changed files with 16 additions and 4 deletions

View file

@ -26,14 +26,20 @@ The `theme` setting can also be set by your used color variant. This will be the
## Usage
Just insert your Mermaid code in the `mermaid` shortcode like this:
Just insert give the URL to your OpenAPI Specification like this:
````go
{{</* swagger src="https://petstore3.swagger.io/api/v3/openapi.json" */>}}
````
The `src` parameter is mandatory and can be either an absolute URL or a relative one pointing into your Hugo file system.
If your page is a leaf or branch bundle, you can also use relative URLs:
````go
{{</* swagger src="petstore.json" */>}}
````
The `src` parameter is mandatory and can be either an absolute or a relative URL.
## Example
{{< swagger src="https://petstore3.swagger.io/api/v3/openapi.json" >}}
{{< swagger src="petstore.json" >}}

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,9 @@
{{- $original := .Get "src" }}
{{- with .Page.Resources.Match $original }}
{{- range . }}
{{- $original = .RelPermalink }}
{{- end }}
{{- end }}
<rapi-doc
allow-spec-file-download="true"
default-schema-tab="example"
@ -9,7 +14,7 @@
schema-description-expanded="true"
schema-style="table"
show-header="false"
spec-url = "{{ $original | relURL }}"
spec-url="{{ $original | relURL }}"
sort-tags="true"
></rapi-doc>
{{- .Page.Store.Set "hasSwagger" true }}