Add templates used to render data

This commit is contained in:
Will 2021-01-29 15:30:39 -08:00 committed by Richard van der Hoff
parent 06983e1eb1
commit 5f45a897ef
17 changed files with 990 additions and 0 deletions

View file

@ -0,0 +1,59 @@
{{/*
This template is used to render EDUs and PDUs in the server-server and room versions specs.
It expects to be passed a `path` parameter, which is a path, relative to /data,
pointing to a schema file. The file extension is omitted. For example:
{{% definition path="api/server-server/definitions/edu" %}}
This template replaces the old {{definition_*}} template.
*/}}
{{ $path := .Params.path }}
{{ $compact := .Params.compact }}
{{ $pieces := split $path "/" }}
{{/* The definition is referenced by the .path parameter */}}
{{ $definition := index .Site.Data $pieces }}
{{/* The base path, which we use to resolve $ref, omits the last component */}}
{{ $pieces = first (sub (len $pieces) 1) $pieces}}
{{ $path = delimit $pieces "/" }}
{{/* Resolve $ref and allOf */}}
{{ $definition = partial "json-schema/resolve-refs" (dict "schema" $definition "path" $path) }}
{{ $definition = partial "json-schema/resolve-allof" $definition }}
<section class="rendered-data definition">
<details {{ if not $compact }}open{{ end }}>
<summary>
<h1>
<code>{{ $definition.title }}</code>
</h1>
<hr/>
{{ $definition.description | markdownify }}
</summary>
{{ $additional_types := partial "json-schema/resolve-additional-types" $definition }}
{{ $additional_types = uniq $additional_types }}
{{ range $additional_types }}
{{ partial "openapi/render-object-table" (dict "caption" .title "properties" .properties "required" .required) }}
{{end}}
<h2>Examples</h2>
{{ $example := partial "json-schema/resolve-example" $definition }}
```json
{{ jsonify (dict "indent" " ") $example }}
```
</section>