From 405b3efbbb2cfae5c350ec226edf914fee8ddf82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Wed, 21 Jun 2023 11:23:29 +0200 Subject: [PATCH] Fix and simplify oneOf branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- .../json-schema/resolve-additional-types.html | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/layouts/partials/json-schema/resolve-additional-types.html b/layouts/partials/json-schema/resolve-additional-types.html index 08ef7619..449b4222 100644 --- a/layouts/partials/json-schema/resolve-additional-types.html +++ b/layouts/partials/json-schema/resolve-additional-types.html @@ -91,17 +91,18 @@ {{ end }} {{ end }} -{{ if and $this_object.oneOf (reflect.IsSlice $this_object.oneOf) }} +{{/* + Handle object schemas using the `oneOf` keyword + (https://json-schema.org/understanding-json-schema/reference/combining.html#oneof) +*/}} +{{ if $this_object.oneOf }} {{ range $idx, $item := $this_object.oneOf }} - /* although we expect resolve-allof to be called on the input, resolve-allof does not recurse into - * nested objects, so we have to call it again. - */ - {{ $item = partial "json-schema/resolve-allof" $item }} - {{ $additional_objects = partial "json-schema/resolve-additional-types" (dict - "schema" $item + {{ $additional_objects = partial "get-additional-objects" (dict + "this_object" $item + "additional_objects" $additional_objects "anchor_base" $anchor_base - "name" (printf "%s.oneOf[%d]" $name $idx)) - }} + "name" (printf "%s.oneOf[%d]" $name $idx) + ) }} {{ end }} {{ end }}