diff --git a/layouts/partials/events/render-event.html b/layouts/partials/events/render-event.html
index f0c50c95..14edbf44 100644
--- a/layouts/partials/events/render-event.html
+++ b/layouts/partials/events/render-event.html
@@ -56,7 +56,11 @@
Content
{{ $anchor_base := anchorize $event_name }}
-{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $event_data.properties.content "anchor_base" $anchor_base) }}
+{{ $additional_types := partial "json-schema/resolve-additional-types" (dict
+ "schema" $event_data.properties.content
+ "anchor_base" $anchor_base
+ "is_root" true
+) }}
{{ $additional_types = uniq $additional_types }}
{{ range $additional_types }}
diff --git a/layouts/partials/json-schema/resolve-additional-types.html b/layouts/partials/json-schema/resolve-additional-types.html
index 8bf210ea..67b9aa42 100644
--- a/layouts/partials/json-schema/resolve-additional-types.html
+++ b/layouts/partials/json-schema/resolve-additional-types.html
@@ -2,6 +2,7 @@
Finds and returns all nested objects, given a dict containing:
* `schema`: a JSON schema object
+ * `is_root`: Whether this is the root of the schema, meaning we should not clean the object so we can show additional and pattern properties.
* `anchor_base`: a prefix to add to the HTML anchors generated for each object. If nil, no anchors are generated.
* `name`: optionally, a name to use for this object in error/warning messages. If left unset,
the object's `title` property is used (if present).
@@ -11,7 +12,7 @@
Assumes that "resolve-refs" and "resolve-allof" has already been called on the
input schema.
- Returns an array of all the objects found. For each object, the following properties are returned:
+ Returns an array of all the objects found. If `is_root` is true, the first object keeps all its properties. For all other objects, the following properties are returned:
* title
* properties
* required
@@ -23,6 +24,7 @@
*/}}
{{ $this_object := .schema }}
+{{ $is_root := .is_root }}
{{ $anchor_base := .anchor_base }}
{{ $additional_objects := slice }}
{{ $name := .name | default $this_object.title | default "" }}
@@ -36,7 +38,11 @@
{{/*
Add the object we were passed into the $additional_objects array
*/}}
- {{ $additional_objects = $additional_objects | append (partial "clean-object" $this_object) }}
+ {{ $this_additional_object := $this_object }}
+ {{ if not $is_root }}
+ {{ $this_additional_object = partial "clean-object" $this_object }}
+ {{ end }}
+ {{ $additional_objects = $additional_objects | append $this_additional_object }}
{{/*
Add any nested objects referenced in this object's `additionalProperties`
diff --git a/layouts/partials/openapi/render-object-table.html b/layouts/partials/openapi/render-object-table.html
index d76f1a74..a99ce6b8 100644
--- a/layouts/partials/openapi/render-object-table.html
+++ b/layouts/partials/openapi/render-object-table.html
@@ -44,19 +44,31 @@
{{ $property_name }} |
{{ partial "partials/property-type" $property }} |
-
- {{ if $required }}Required: {{end -}}
- {{ $property.description | markdownify -}}
- {{ if $property.enum }} One of: [{{ delimit $property.enum ", " }}]. {{ end -}}
- {{ if (index $property "x-addedInMatrixVersion") }}{{ partial "added-in" (dict "v" (index $property "x-addedInMatrixVersion")) }}{{ end -}}
- {{ if (index $property "x-changedInMatrixVersion") }}{{ partial "changed-in" (dict "changes_dict" (index $property "x-changedInMatrixVersion")) }}{{ end -}}
- |
+ {{ partial "partials/property-description" (dict "property" $property "required" $required) }} |
{{ end }}
+{{ else if (or .additionalProperties .patternProperties) }}
+
+ {{ with $title }}
+ {{ . }}
+ {{ end }}
+
+ | Type |
+ Description |
+
+
+ {{ $property := partial "json-schema/resolve-allof" . }}
+
+
+ {{ partial "partials/property-type" $property }} |
+ {{ partial "partials/property-description" (dict "property" $property) }} |
+
+
+
{{ end }}
{{/*
@@ -148,3 +160,14 @@
{{ end }}
{{ return $type }}
{{ end }}
+
+{{/*
+ Computes the description to display for a property.
+*/}}
+{{ define "partials/property-description" }}
+ {{ if .required }}Required: {{end -}}
+ {{ .property.description | markdownify -}}
+ {{ if .property.enum }}One of: [{{ delimit .property.enum ", " }}].
{{ end -}}
+ {{ if (index .property "x-addedInMatrixVersion") }}{{ partial "added-in" (dict "v" (index .property "x-addedInMatrixVersion")) }}{{ end -}}
+ {{ if (index .property "x-changedInMatrixVersion") }}{{ partial "changed-in" (dict "changes_dict" (index .property "x-changedInMatrixVersion")) }}{{ end -}}
+{{ end }}
\ No newline at end of file
diff --git a/layouts/partials/openapi/render-request.html b/layouts/partials/openapi/render-request.html
index ce31943c..d9fcf8c0 100644
--- a/layouts/partials/openapi/render-request.html
+++ b/layouts/partials/openapi/render-request.html
@@ -45,7 +45,7 @@
{{ $schema := partial "json-schema/resolve-refs" (dict "schema" $json_body.schema "path" $path) }}
{{ $schema := partial "json-schema/resolve-allof" $schema }}
- {{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $schema "anchor_base" $anchor_base) }}
+ {{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $schema "anchor_base" $anchor_base "is_root" true) }}
{{ $additional_types = uniq $additional_types }}
{{ range $additional_types }}
{{ partial "openapi/render-object-table" . }}
diff --git a/layouts/partials/openapi/render-responses.html b/layouts/partials/openapi/render-responses.html
index 37538b6e..b78efd20 100644
--- a/layouts/partials/openapi/render-responses.html
+++ b/layouts/partials/openapi/render-responses.html
@@ -80,7 +80,7 @@
response. (This will be a no-op for response types which aren't
objects or arrays.)
*/}}
- {{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $schema "anchor_base" $anchor_base) }}
+ {{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $schema "anchor_base" $anchor_base "is_root" true) }}
{{ $additional_types = uniq $additional_types }}
{{ range $additional_types }}
{{ partial "openapi/render-object-table" . }}
diff --git a/layouts/shortcodes/definition.html b/layouts/shortcodes/definition.html
index 67cd63c0..77ea2d5c 100644
--- a/layouts/shortcodes/definition.html
+++ b/layouts/shortcodes/definition.html
@@ -50,7 +50,7 @@
{{ $definition.description | markdownify }}
-{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $definition "name" (printf "\"%s\"" $path)) }}
+{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $definition "name" (printf "\"%s\"" $path)) "is_root" true }}
{{ $additional_types = uniq $additional_types }}
{{ range $additional_types }}
diff --git a/layouts/shortcodes/event-fields.html b/layouts/shortcodes/event-fields.html
index 91e2faf2..d45ead0d 100644
--- a/layouts/shortcodes/event-fields.html
+++ b/layouts/shortcodes/event-fields.html
@@ -35,7 +35,7 @@
{{ $event = merge $event (dict "title" "") }}
-{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $event) }}
+{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $event) "is_root" true }}
{{ range $additional_types }}
{{ partial "openapi/render-object-table" . }}
{{end}}