mirror of
https://github.com/matrix-org/matrix-spec
synced 2026-05-01 22:54:10 +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).
|
||||
*/
|
||||
|
||||
{{ 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 }}
|
||||
{{ $anchor_base := .anchor_base }}
|
||||
{{ $name := .name }}
|
||||
{{ $all_objects := slice }}
|
||||
{{ $name := .name | default $this_object.title | default "<untitled object>" }}
|
||||
|
||||
{{ if eq $this_object.type "object" }}
|
||||
/* Give this object an anchor, if it has a name */
|
||||
|
|
@ -131,7 +145,7 @@
|
|||
{{ end }}
|
||||
|
||||
{{ return uniq $all_objects }}
|
||||
|
||||
{{ end }}
|
||||
|
||||
/* 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 }}
|
||||
|
||||
{{ $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}}
|
||||
{{ $all_objects = $all_objects | append (partial "clean-object" .) }}
|
||||
{{ end }}
|
||||
|
|
|
|||
Loading…
Reference in a new issue