mirror of
https://github.com/matrix-org/matrix-spec
synced 2026-04-29 22:04:08 +02:00
Extract an inner helper for resolve-additional-types
This commit is contained in:
parent
3fee99616b
commit
4043c1fc58
|
|
@ -44,10 +44,24 @@
|
||||||
* referenced twice within `schema`, it will only be returned once).
|
* referenced twice within `schema`, it will only be returned once).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
{{ return partial "resolve-additional-types-inner" (dict
|
||||||
|
"schema" .schema
|
||||||
|
"anchor_base" .anchor_base
|
||||||
|
"name" (.name | default .schema.title | default "<untitled object>")
|
||||||
|
) }}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A helper for the resolve-additional-types partial.
|
||||||
|
*
|
||||||
|
* Takes the same inputs as resolve-additional-types itself, except that `name` is mandatory.
|
||||||
|
*
|
||||||
|
* Returns the array of object schema definitions.
|
||||||
|
*/
|
||||||
|
{{ define "partials/resolve-additional-types-inner" }}
|
||||||
{{ $this_object := .schema }}
|
{{ $this_object := .schema }}
|
||||||
{{ $anchor_base := .anchor_base }}
|
{{ $anchor_base := .anchor_base }}
|
||||||
|
{{ $name := .name }}
|
||||||
{{ $all_objects := slice }}
|
{{ $all_objects := slice }}
|
||||||
{{ $name := .name | default $this_object.title | default "<untitled object>" }}
|
|
||||||
|
|
||||||
{{ if eq $this_object.type "object" }}
|
{{ if eq $this_object.type "object" }}
|
||||||
/* Give this object an anchor, if it has a name */
|
/* Give this object an anchor, if it has a name */
|
||||||
|
|
@ -131,7 +145,7 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ return uniq $all_objects }}
|
{{ return uniq $all_objects }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
/* This actually makes the recursive call and adds the returned object schema definitions to the array.
|
/* This actually makes the recursive call and adds the returned object schema definitions to the array.
|
||||||
*
|
*
|
||||||
|
|
@ -159,7 +173,7 @@
|
||||||
*/
|
*/
|
||||||
{{ $this_object := partial "json-schema/resolve-allof" .this_object }}
|
{{ $this_object := partial "json-schema/resolve-allof" .this_object }}
|
||||||
|
|
||||||
{{ $more_objects := partial "json-schema/resolve-additional-types" (dict "schema" $this_object "anchor_base" .anchor_base "name" $name) }}
|
{{ $more_objects := partial "resolve-additional-types-inner" (dict "schema" $this_object "anchor_base" .anchor_base "name" $name) }}
|
||||||
{{ range $more_objects}}
|
{{ range $more_objects}}
|
||||||
{{ $all_objects = $all_objects | append (partial "clean-object" .) }}
|
{{ $all_objects = $all_objects | append (partial "clean-object" .) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue