docs-matrix-spec/layouts/shortcodes/http-api.html
Kévin Commaille e82829d4a2
Make resolve-allof partial recursive (#1787)
Makes it easier to use, like resolve-refs. It just needs to be called once.

Fixes an issue with m.call.* events not displaying the common fields

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
2024-04-17 09:29:34 +01:00

29 lines
1,009 B
HTML

{{/*
This template is used to render an HTTP API, given an OpenAPI definition.
It expects to be passed two parameters:
* a `spec` parameter identifying the spec, which must be the name of
a directory under /data/api
* an `api` parameter, identifying an OpenAPI definition,
which is the name of a schema file under "data/api/$spec".
The file extension is omitted. For example:
{{% http-api spec="server-server" api="public_rooms" %}}
This template replaces the old {{*_http_api}} template.
*/}}
{{ $spec := .Params.spec}}
{{ $api := .Params.api}}
{{ $api_data := index .Site.Data.api .Params.spec .Params.api }}
{{ $base_url := (index $api_data.servers 0).variables.basePath.default }}
{{ $path := delimit (slice "api" $spec $api) "/" }}
{{ $api_data = partial "json-schema/resolve-refs" (dict "schema" $api_data "path" $path) }}
{{ $api_data = partial "json-schema/resolve-allof" $api_data }}
{{ partial "openapi/render-api" (dict "api_data" $api_data "base_url" $base_url) }}