mirror of
https://github.com/matrix-org/matrix-spec
synced 2026-03-26 04:54:10 +01:00
Support rendering of patternProperties
Currently the pattern is ignored as there is always only one pattern in current definitions, and the pattern is clear with the descriptions. First step to render `m.receipt` event Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
parent
4ca33aec90
commit
7838d32596
|
|
@ -52,6 +52,20 @@
|
|||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/*
|
||||
Add any nested objects referenced in this object's `patternProperties`
|
||||
*/}}
|
||||
{{ if $this_object.patternProperties }}
|
||||
{{ range $pattern, $object := $this_object.patternProperties}}
|
||||
{{ $additional_objects = partial "get-additional-objects" (dict
|
||||
"this_object" $object
|
||||
"additional_objects" $additional_objects
|
||||
"anchor_base" $anchor_base
|
||||
"name" (printf "%s.pattern.%s" $name $pattern)
|
||||
) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/*
|
||||
Add any nested objects referenced in this object's `properties`
|
||||
*/}}
|
||||
|
|
|
|||
|
|
@ -104,6 +104,22 @@
|
|||
*/}}
|
||||
{{ $additionalProperties := partial "json-schema/resolve-allof" .additionalProperties }}
|
||||
{{ $type = delimit (slice "{string: " (partial "property-type" $additionalProperties) "}" ) "" }}
|
||||
{{ else if reflect.IsMap .patternProperties }}
|
||||
{{/*
|
||||
If the property uses `patternProperties` to describe its
|
||||
internal structure, handle this with a bit of recursion.
|
||||
Note that we ignore the pattern as the current definitions
|
||||
always have a single pattern, but we might need to handle
|
||||
them later to differentiate schemas according to patterns.
|
||||
*/}}
|
||||
{{ $types := slice }}
|
||||
|
||||
{{ range $pattern, $schema := .patternProperties}}
|
||||
{{ $schema = partial "json-schema/resolve-allof" $schema }}
|
||||
{{ $types = $types | append (partial "property-type" $schema) }}
|
||||
{{ end }}
|
||||
|
||||
{{ $type = delimit (slice "{string: " (delimit $types "|") "}" ) "" }}
|
||||
{{ else if reflect.IsSlice .type }}
|
||||
{{/* It's legal to specify an array of types. Join them together in that case */}}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue