mirror of
https://github.com/matrix-org/matrix-spec
synced 2026-04-04 18:24:10 +02:00
resolve-addtional-types: include generated anchor ids in returned data
This commit is contained in:
parent
630bfa497e
commit
5f50277f13
|
|
@ -13,7 +13,10 @@
|
||||||
|
|
||||||
Returns a pair [$updated_definition, $additional_objects], where:
|
Returns a pair [$updated_definition, $additional_objects], where:
|
||||||
|
|
||||||
$updated_definition: TODO
|
$updated_definition: Largely the same as the provided `schema`, except for the addition of an `anchor` property
|
||||||
|
for any objects we decided to generate anchors for.
|
||||||
|
|
||||||
|
For objects, this is the same as the first entry in `$additional_objects`.
|
||||||
|
|
||||||
$additional_objects is an array of all the objects found. For each object, the following properties are returned:
|
$additional_objects is an array of all the objects found. For each object, the following properties are returned:
|
||||||
* title
|
* title
|
||||||
|
|
@ -37,11 +40,6 @@
|
||||||
{{ $this_object = merge $this_object (dict "anchor" (printf "%s_%s" $anchor_base (anchorize $this_object.title))) }}
|
{{ $this_object = merge $this_object (dict "anchor" (printf "%s_%s" $anchor_base (anchorize $this_object.title))) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{/*
|
|
||||||
Add the object we were passed into the $additional_objects array
|
|
||||||
*/}}
|
|
||||||
{{ $additional_objects = $additional_objects | append (partial "clean-object" $this_object) }}
|
|
||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
Add any nested objects referenced in this object's `additionalProperties`
|
Add any nested objects referenced in this object's `additionalProperties`
|
||||||
*/}}
|
*/}}
|
||||||
|
|
@ -56,12 +54,16 @@
|
||||||
{{ with $more_objects := index $res 1 }}
|
{{ with $more_objects := index $res 1 }}
|
||||||
{{ $additional_objects = $additional_objects | append $more_objects }}
|
{{ $additional_objects = $additional_objects | append $more_objects }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{/* update the object definition with any updates from the additional properties */}}
|
||||||
|
{{ $this_object = merge $this_object (dict "additionalProperties" (index $res 0)) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
Add any nested objects referenced in this object's `properties`
|
Add any nested objects referenced in this object's `properties`
|
||||||
*/}}
|
*/}}
|
||||||
|
{{ $updated_properties := dict }}
|
||||||
{{ range $key, $property := $this_object.properties}}
|
{{ range $key, $property := $this_object.properties}}
|
||||||
{{ $res := partial "get-additional-objects" (dict
|
{{ $res := partial "get-additional-objects" (dict
|
||||||
"this_object" $property
|
"this_object" $property
|
||||||
|
|
@ -71,8 +73,20 @@
|
||||||
{{ with $more_objects := index $res 1 }}
|
{{ with $more_objects := index $res 1 }}
|
||||||
{{ $additional_objects = $additional_objects | append $more_objects }}
|
{{ $additional_objects = $additional_objects | append $more_objects }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ $updated_properties = merge $updated_properties (dict $key (index $res 0)) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{/* update the object definition with any updates from the properties */}}
|
||||||
|
{{ $this_object = merge $this_object (dict "properties" $updated_properties) }}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Add the updated object to the front of the $additional_objects array
|
||||||
|
*/}}
|
||||||
|
{{ $res := slice (partial "clean-object" $this_object) }}
|
||||||
|
{{ if $additional_objects }}
|
||||||
|
{{ $res = $res | append $additional_objects }}
|
||||||
|
{{ end }}
|
||||||
|
{{ $additional_objects = $res }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ if eq $this_object.type "array" }}
|
{{ if eq $this_object.type "array" }}
|
||||||
|
|
@ -99,6 +113,7 @@
|
||||||
{{ with $more_objects := index $res 1 }}
|
{{ with $more_objects := index $res 1 }}
|
||||||
{{ $additional_objects = $additional_objects | append $more_objects }}
|
{{ $additional_objects = $additional_objects | append $more_objects }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ $this_object = merge $this_object (dict "items" (index $res 0)) }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ errorf "%s is defined as an 'array' but lacks a valid 'items'" $name }}
|
{{ errorf "%s is defined as an 'array' but lacks a valid 'items'" $name }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue