{{/* Renders a single event, given: * `event_name`: the name we want to display for the event * `event_data`: the event specification * `desired_example_name` (optional): the exact name of the examples to render. If `desired_example_name` is omitted we render all examples whose names start with the `event_name`. */}} {{ $event_name := .event_name }} {{ $desired_example_name := .desired_example_name }} {{ $event_data := .event_data }}

{{ $event_name }}


{{ $event_data.description | markdownify }}
{{ $state_key := index $event_data.properties "state_key" }} {{ if $state_key }} {{ end }}
Event type: {{ if $state_key }}State event{{ else }}Message event{{ end }}
State key {{ $state_key.description | markdownify }}

Content

{{ $additional_types := partial "json-schema/resolve-additional-types" $event_data.properties.content }} {{ range $additional_types }} {{ partial "openapi/render-object-table" (dict "caption" .title "properties" .properties "required" .required) }} {{end}}

Examples

{{ $all_examples := index site.Data "event-schemas" "examples" }} {{ range $example_name, $example := $all_examples }} {{/* This is to allow the msgtype template to work. It lets callers specify exactly the name of the example they want */}} {{ if $desired_example_name }} {{ if eq $example_name $desired_example_name }} {{ $example_content := partial "json-schema/resolve-refs" (dict "schema" $example "path" "event-schemas/examples") }} ```json {{ jsonify (dict "indent" " ") $example_content }} ``` {{ end }} {{/* If `$desired_example_name` is not given, we will include any examples whose first part (before "$") matches the event name */}} {{ else }} {{ $pieces := split $example_name "$" }} {{ $example_base_name := index $pieces 0 }} {{ if eq $event_name $example_base_name }} {{ $example_content := partial "json-schema/resolve-refs" (dict "schema" $example "path" "event-schemas/examples") }} {{ $example_json := jsonify (dict "indent" " ") $example_content }} {{ $example_json = replace $example_json "\\u003c" "<" }} {{ $example_json = replace $example_json "\\u003e" ">" | safeHTML }} ```json {{ $example_json }} ``` {{ end }} {{ end }} {{ end }}