-
-
Notifications
You must be signed in to change notification settings - Fork 90
/
definition.html
67 lines (44 loc) · 1.81 KB
/
definition.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{{/*
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 }}
{{ if not $definition }}
{{ errorf "site data %s not found" $path }}
{{ end }}
{{/* 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" id="definition-{{ anchorize $definition.title }}">
<details {{ if not $compact }}open{{ end }}>
<summary>
<h1>
<code>{{ $definition.title }}</code>
</h1>
<hr/>
{{ if (index $definition "x-addedInMatrixVersion") }}
{{ partial "added-in" (dict "v" (index $definition "x-addedInMatrixVersion")) }}
{{ end }}
{{ $definition.description | markdownify }}
</summary>
{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $definition) }}
{{ $additional_types = uniq $additional_types }}
{{ range $additional_types }}
{{ partial "openapi/render-object-table" . }}
{{end}}
<h2>Examples</h2>
{{ $example := partial "json-schema/resolve-example" $definition }}
```json
{{ jsonify (dict "indent" " ") $example }}
```
</section>