Skip to content

Commit

Permalink
Fix anchors for schemas under oneOf (#1799)
Browse files Browse the repository at this point in the history
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
  • Loading branch information
zecakeh authored Apr 24, 2024
1 parent 2edfb21 commit 7201042
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelogs/internal/newsfragments/1799.clarification
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix anchors for schemas under `oneOf`.
5 changes: 5 additions & 0 deletions layouts/partials/json-schema/resolve-additional-types.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
* (https://json-schema.org/understanding-json-schema/reference/combining.html#oneof)
*/
{{ if $this_object.oneOf }}
{{ $updated_items := slice }}
{{ range $idx, $item := $this_object.oneOf }}
{{ $res := partial "get-additional-objects" (dict
"this_object" $item
Expand All @@ -173,7 +174,11 @@
"name" (printf "%s.oneOf[%d]" $name $idx)
) }}
{{ $all_objects = $res.objects }}
{{ $updated_items = $updated_items | append $res.schema }}
{{ end }}

/* Update the top-level schema with the updated subschemas for the items */
{{ $this_object = merge $this_object (dict "oneOf" $updated_items) }}
{{ end }}

{{ return (dict
Expand Down

0 comments on commit 7201042

Please sign in to comment.