Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelogs/internal/newsfragments/2069.clarification
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix parsing of nested slices in `resolve-refs` and `resolve-allof` partials.
8 changes: 8 additions & 0 deletions layouts/partials/json-schema/resolve-allof.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
8 changes: 8 additions & 0 deletions layouts/partials/json-schema/resolve-refs.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down