diff --git a/changelogs/internal/newsfragments/2069.clarification b/changelogs/internal/newsfragments/2069.clarification new file mode 100644 index 00000000..2ad407fb --- /dev/null +++ b/changelogs/internal/newsfragments/2069.clarification @@ -0,0 +1 @@ +Fix parsing of nested slices in `resolve-refs` and `resolve-allof` partials. 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 }}