From 7201042894dfcaf8da468d3bcb6e9a60805baaa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= <76261501+zecakeh@users.noreply.github.com> Date: Wed, 24 Apr 2024 13:53:49 +0200 Subject: [PATCH] Fix anchors for schemas under `oneOf` (#1799) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- changelogs/internal/newsfragments/1799.clarification | 1 + layouts/partials/json-schema/resolve-additional-types.html | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 changelogs/internal/newsfragments/1799.clarification diff --git a/changelogs/internal/newsfragments/1799.clarification b/changelogs/internal/newsfragments/1799.clarification new file mode 100644 index 00000000..d47e0183 --- /dev/null +++ b/changelogs/internal/newsfragments/1799.clarification @@ -0,0 +1 @@ +Fix anchors for schemas under `oneOf`. diff --git a/layouts/partials/json-schema/resolve-additional-types.html b/layouts/partials/json-schema/resolve-additional-types.html index 157045b5..cf5e9953 100644 --- a/layouts/partials/json-schema/resolve-additional-types.html +++ b/layouts/partials/json-schema/resolve-additional-types.html @@ -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 @@ -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