* Use the resolve-refs partial as soon as possible Call it right after accessing the site.Data, since it is recursing it will solve all references in the tree. That way we don't need to wonder where to call it, we trust the validators that the refs will be used in the right place. * Enable strict $ref rule in OpenAPI validator * Document use of $ref to compose examples * Fix schema path in event-fields shortcode Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
28 lines
945 B
HTML
28 lines
945 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) }}
|
|
|
|
{{ partial "openapi/render-api" (dict "api_data" $api_data "base_url" $base_url) }}
|