mirror of
https://github.com/matrix-org/matrix-spec
synced 2026-02-26 07:53:43 +01:00
Return a second value from resolve-additional-types
This commit is contained in:
parent
f58d24e532
commit
630bfa497e
|
|
@ -56,7 +56,7 @@
|
||||||
<h2>Content</h2>
|
<h2>Content</h2>
|
||||||
|
|
||||||
{{ $anchor_base := anchorize $event_name }}
|
{{ $anchor_base := anchorize $event_name }}
|
||||||
{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $event_data.properties.content "anchor_base" $anchor_base) }}
|
{{ $additional_types := index (partial "json-schema/resolve-additional-types" (dict "schema" $event_data.properties.content "anchor_base" $anchor_base)) 1 }}
|
||||||
|
|
||||||
{{ range $additional_types }}
|
{{ range $additional_types }}
|
||||||
{{ partial "openapi/render-object-table" . }}
|
{{ partial "openapi/render-object-table" . }}
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,18 @@
|
||||||
Assumes that "resolve-refs" and "resolve-allof" has already been called on the
|
Assumes that "resolve-refs" and "resolve-allof" has already been called on the
|
||||||
input schema.
|
input schema.
|
||||||
|
|
||||||
Returns an array of all the objects found. For each object, the following properties are returned:
|
Returns a pair [$updated_definition, $additional_objects], where:
|
||||||
* title
|
|
||||||
* properties
|
|
||||||
* required
|
|
||||||
* enum
|
|
||||||
* anchor: a string suitable for using as an html anchor for this object (if `anchor_base` was set, and the object has a title)
|
|
||||||
|
|
||||||
Note that the returned array may contain duplicate objects.
|
$updated_definition: TODO
|
||||||
|
|
||||||
|
$additional_objects is an array of all the objects found. For each object, the following properties are returned:
|
||||||
|
* title
|
||||||
|
* properties
|
||||||
|
* required
|
||||||
|
* enum
|
||||||
|
* anchor: a string suitable for using as an html anchor for this object (if `anchor_base` was set, and the object has a title)
|
||||||
|
|
||||||
|
Note that the returned array may contain duplicate objects.
|
||||||
|
|
||||||
*/}}
|
*/}}
|
||||||
|
|
||||||
|
|
@ -43,13 +47,13 @@
|
||||||
*/}}
|
*/}}
|
||||||
{{ if $this_object.additionalProperties }}
|
{{ if $this_object.additionalProperties }}
|
||||||
{{ if reflect.IsMap $this_object.additionalProperties }}
|
{{ if reflect.IsMap $this_object.additionalProperties }}
|
||||||
{{ $more_objects = partial "get-additional-objects" (dict
|
{{ $res := partial "get-additional-objects" (dict
|
||||||
"this_object" $this_object.additionalProperties
|
"this_object" $this_object.additionalProperties
|
||||||
"anchor_base" $anchor_base
|
"anchor_base" $anchor_base
|
||||||
"name" (printf "%s.additional" $name)
|
"name" (printf "%s.additional" $name)
|
||||||
) }}
|
) }}
|
||||||
{{/* appending an empty slice messes up the types and confuses go, so only do the append if $more_objects is non-empty */}}
|
{{/* appending an empty slice messes up the types and confuses go, so only do the append if $more_objects is non-empty */}}
|
||||||
{{ if $more_objects }}
|
{{ with $more_objects := index $res 1 }}
|
||||||
{{ $additional_objects = $additional_objects | append $more_objects }}
|
{{ $additional_objects = $additional_objects | append $more_objects }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
@ -59,12 +63,12 @@
|
||||||
Add any nested objects referenced in this object's `properties`
|
Add any nested objects referenced in this object's `properties`
|
||||||
*/}}
|
*/}}
|
||||||
{{ range $key, $property := $this_object.properties}}
|
{{ range $key, $property := $this_object.properties}}
|
||||||
{{ $more_objects := partial "get-additional-objects" (dict
|
{{ $res := partial "get-additional-objects" (dict
|
||||||
"this_object" $property
|
"this_object" $property
|
||||||
"anchor_base" $anchor_base
|
"anchor_base" $anchor_base
|
||||||
"name" (printf "%s.%s" $name $key)
|
"name" (printf "%s.%s" $name $key)
|
||||||
) }}
|
) }}
|
||||||
{{ if $more_objects }}
|
{{ with $more_objects := index $res 1 }}
|
||||||
{{ $additional_objects = $additional_objects | append $more_objects }}
|
{{ $additional_objects = $additional_objects | append $more_objects }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
@ -77,22 +81,22 @@
|
||||||
*/}}
|
*/}}
|
||||||
{{ if reflect.IsSlice $this_object.items}}
|
{{ if reflect.IsSlice $this_object.items}}
|
||||||
{{ range $idx, $item := $this_object.items }}
|
{{ range $idx, $item := $this_object.items }}
|
||||||
{{ $more_objects := partial "get-additional-objects" (dict
|
{{ $res := partial "get-additional-objects" (dict
|
||||||
"this_object" $item
|
"this_object" $item
|
||||||
"anchor_base" $anchor_base
|
"anchor_base" $anchor_base
|
||||||
"name" (printf "%s.items[%d]" $name $idx)
|
"name" (printf "%s.items[%d]" $name $idx)
|
||||||
) }}
|
) }}
|
||||||
{{ if $more_objects }}
|
{{ with $more_objects := index $res 1 }}
|
||||||
{{ $additional_objects = $additional_objects | append $more_objects }}
|
{{ $additional_objects = $additional_objects | append $more_objects }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else if reflect.IsMap $this_object.items}}
|
{{ else if reflect.IsMap $this_object.items}}
|
||||||
{{ $more_objects := partial "get-additional-objects" (dict
|
{{ $res := partial "get-additional-objects" (dict
|
||||||
"this_object" $this_object.items
|
"this_object" $this_object.items
|
||||||
"anchor_base" $anchor_base
|
"anchor_base" $anchor_base
|
||||||
"name" (printf "%s.items" $name)
|
"name" (printf "%s.items" $name)
|
||||||
) }}
|
) }}
|
||||||
{{ if $more_objects }}
|
{{ with $more_objects := index $res 1 }}
|
||||||
{{ $additional_objects = $additional_objects | append $more_objects }}
|
{{ $additional_objects = $additional_objects | append $more_objects }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
|
|
@ -100,7 +104,7 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ return $additional_objects }}
|
{{ return slice $this_object $additional_objects }}
|
||||||
|
|
||||||
|
|
||||||
{{/*
|
{{/*
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
{{ $schema := partial "json-schema/resolve-refs" (dict "schema" $body_parameter.schema "path" $path) }}
|
{{ $schema := partial "json-schema/resolve-refs" (dict "schema" $body_parameter.schema "path" $path) }}
|
||||||
{{ $schema := partial "json-schema/resolve-allof" $schema }}
|
{{ $schema := partial "json-schema/resolve-allof" $schema }}
|
||||||
|
|
||||||
{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $schema "anchor_base" $anchor_base) }}
|
{{ $additional_types := index (partial "json-schema/resolve-additional-types" (dict "schema" $schema "anchor_base" $anchor_base)) 1 }}
|
||||||
{{ $additional_types = uniq $additional_types }}
|
{{ $additional_types = uniq $additional_types }}
|
||||||
{{ range $additional_types }}
|
{{ range $additional_types }}
|
||||||
{{ partial "openapi/render-object-table" . }}
|
{{ partial "openapi/render-object-table" . }}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@
|
||||||
response. (This will be a no-op for response types which aren't
|
response. (This will be a no-op for response types which aren't
|
||||||
objects or arrays.)
|
objects or arrays.)
|
||||||
*/}}
|
*/}}
|
||||||
{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $schema "anchor_base" $anchor_base) }}
|
{{ $additional_types := index (partial "json-schema/resolve-additional-types" (dict "schema" $schema "anchor_base" $anchor_base)) 1 }}
|
||||||
{{ $additional_types = uniq $additional_types }}
|
{{ $additional_types = uniq $additional_types }}
|
||||||
{{ range $additional_types }}
|
{{ range $additional_types }}
|
||||||
{{ partial "openapi/render-object-table" . }}
|
{{ partial "openapi/render-object-table" . }}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
|
|
||||||
</summary>
|
</summary>
|
||||||
|
|
||||||
{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $definition "name" (printf "\"%s\"" $path)) }}
|
{{ $additional_types := index (partial "json-schema/resolve-additional-types" (dict "schema" $definition "name" (printf "\"%s\"" $path))) 1 }}
|
||||||
{{ $additional_types = uniq $additional_types }}
|
{{ $additional_types = uniq $additional_types }}
|
||||||
|
|
||||||
{{ range $additional_types }}
|
{{ range $additional_types }}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
{{ $event = merge $event (dict "title" "") }}
|
{{ $event = merge $event (dict "title" "") }}
|
||||||
|
|
||||||
{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $event) }}
|
{{ $additional_types := index (partial "json-schema/resolve-additional-types" (dict "schema" $event)) 1 }}
|
||||||
{{ range $additional_types }}
|
{{ range $additional_types }}
|
||||||
{{ partial "openapi/render-object-table" . }}
|
{{ partial "openapi/render-object-table" . }}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue