docs-matrix-spec/layouts/shortcodes/event-fields.html
Kévin Commaille 2678370f2c
Simplify uses of resolve-refs partial (#1773)
* 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>
2024-04-09 18:06:53 +01:00

45 lines
1.2 KiB
HTML

{{/*
This template is used to render the fields that all basic events and room events
must or may contain.
It expects to be passed an `event_type` parameter, is the name of a file under
/data/event-schemas/core-event-schema. The file extension is omitted. For example:
{{% event-fields event_type="room_event" %}}
This template replaces the old {{common_event_fields}} and {{common_room_event_fields}} templates.
*/}}
{{ $event := index .Site.Data "event-schemas" "schema" "core-event-schema" .Params.event_type }}
{{ $path := delimit (slice "event-schemas/schema/core-event-schema" .Params.event_type) "/" }}
{{ $event = partial "json-schema/resolve-refs" (dict "schema" $event "path" $path) }}
{{ $event := partial "json-schema/resolve-allof" $event }}
<section class="rendered-data event">
<details {{ if not .Site.Params.ui.rendered_data_collapsed }}open{{ end }}>
<summary>
<h1>
<code>{{ humanize $event.title }}</code>
</h1>
</summary>
<hr/>
{{ $event.description | markdownify }}
{{ $event = merge $event (dict "title" "") }}
{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $event) }}
{{ range $additional_types }}
{{ partial "openapi/render-object-table" . }}
{{end}}
</details>
</section>