mirror of
https://github.com/matrix-org/matrix-spec
synced 2026-03-23 03:34:08 +01:00
Fix rendering of array with items using anyOf
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
parent
27e71fff10
commit
5a83ac78f2
|
|
@ -155,6 +155,7 @@
|
|||
{{ if eq $this_object.type "array" }}
|
||||
/* Add any nested objects referenced in this object's `items` */
|
||||
{{ if $this_object.items.anyOf }}
|
||||
{{ $updated_schemas := slice }}
|
||||
{{ range $idx, $item := $this_object.items.anyOf }}
|
||||
{{ $res := partial "get-additional-objects" (dict
|
||||
"this_object" $item
|
||||
|
|
@ -163,7 +164,10 @@
|
|||
"name" (printf "%s.items[%d]" $name $idx)
|
||||
) }}
|
||||
{{ $all_objects = $res.objects }}
|
||||
{{ $updated_schemas = $updated_schemas | append $res.schema }}
|
||||
{{ end }}
|
||||
/* Update the top-level schema with the updated subschemas for the items */
|
||||
{{ $this_object = merge $this_object (dict "items" (dict "anyOf" $updated_schemas)) }}
|
||||
{{ else if reflect.IsMap $this_object.items}}
|
||||
{{ $res := partial "get-additional-objects" (dict
|
||||
"this_object" $this_object.items
|
||||
|
|
|
|||
|
|
@ -117,6 +117,9 @@ resolve-additional-types.)
|
|||
|
||||
* `oneOf`: optional array of dictionaries describing the different formats
|
||||
that the property can have
|
||||
|
||||
* `anyOf`: optional array of dictionaries describing the different formats
|
||||
that the property can have
|
||||
|
||||
* `properties`: if the type is an object, optional dictionary for
|
||||
well-defined properties, each given as: `property_name` : `property_data`
|
||||
|
|
@ -158,13 +161,14 @@ resolve-additional-types.)
|
|||
{{ $type = . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else if or (reflect.IsSlice .type) .oneOf }}
|
||||
{{ else if or (reflect.IsSlice .type) .oneOf .anyOf }}
|
||||
{{/*
|
||||
It's legal to specify an array of types.
|
||||
|
||||
There are two ways to do that:
|
||||
There are three ways to do that:
|
||||
- Use an array of strings.
|
||||
- Use oneOf, with items having a schema.
|
||||
- Use anyOf, with items having a schema.
|
||||
|
||||
Join them together in that case, like `type|other_type`.
|
||||
*/}}
|
||||
|
|
@ -174,6 +178,10 @@ resolve-additional-types.)
|
|||
{{ range .oneOf }}
|
||||
{{ $types = $types | append (partial "property-type" .) }}
|
||||
{{ end }}
|
||||
{{ else if .anyOf }}
|
||||
{{ range .anyOf }}
|
||||
{{ $types = $types | append (partial "property-type" .) }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ range .type }}
|
||||
{{ $types = $types | append (htmlEscape .) }}
|
||||
|
|
|
|||
Loading…
Reference in a new issue