Fix parsing of nested slices in resolve-refs and resolve-allof partials (#2069)

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
Kévin Commaille 2025-03-04 18:14:42 +01:00 committed by GitHub
parent 60339adb2d
commit dfc61ffc71
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 0 deletions

View file

@ -0,0 +1 @@
Fix parsing of nested slices in `resolve-refs` and `resolve-allof` partials.

View file

@ -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 }}

View file

@ -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 }}