From d94e0ae8c218e16042b282397d55ae23cf69998b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Fri, 7 Feb 2025 10:52:09 +0100 Subject: [PATCH] Fix parsing of nested slices in resolve-refs and resolve-allof partials MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- layouts/partials/json-schema/resolve-allof.html | 8 ++++++++ layouts/partials/json-schema/resolve-refs.html | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/layouts/partials/json-schema/resolve-allof.html b/layouts/partials/json-schema/resolve-allof.html index b8b81e7d..61a03c3f 100644 --- a/layouts/partials/json-schema/resolve-allof.html +++ b/layouts/partials/json-schema/resolve-allof.html @@ -24,6 +24,14 @@ {{ range $original }} {{ $resolved := partial "json-schema/resolve-allof" . }} + {{ if reflect.IsSlice $resolved }} + {{/* + If $resolved is a slice, `append` will add the items of $resolved to + $ret, but we want to add $resolved itself to $ret, so we always wrap + it into another slice. + */}} + {{ $resolved = slice $resolved }} + {{ end }} {{ $ret = $ret | append $resolved }} {{ end }} {{ else if reflect.IsMap $original }} diff --git a/layouts/partials/json-schema/resolve-refs.html b/layouts/partials/json-schema/resolve-refs.html index 9a36e413..7479498a 100644 --- a/layouts/partials/json-schema/resolve-refs.html +++ b/layouts/partials/json-schema/resolve-refs.html @@ -69,6 +69,14 @@ {{ range $schema }} {{ $resolved := partial "json-schema/resolve-refs" (dict "schema" . "path" $path) }} + {{ if reflect.IsSlice $resolved }} + {{/* + If $resolved is a slice, `append` will add the items of $resolved to + $result_slice, but we want to add $resolved itself to $result_slice, + so we wrap it into another slice. + */}} + {{ $resolved = slice $resolved }} + {{ end }} {{ $result_slice = $result_slice | append $resolved }} {{ end }}