Fix and simplify oneOf branch

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
Kévin Commaille 2023-06-21 11:23:29 +02:00
parent 33440233c2
commit 405b3efbbb
No known key found for this signature in database
GPG key ID: 29A48C1F03620416

View file

@ -91,17 +91,18 @@
{{ end }} {{ end }}
{{ 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 }} {{ range $idx, $item := $this_object.oneOf }}
/* although we expect resolve-allof to be called on the input, resolve-allof does not recurse into {{ $additional_objects = partial "get-additional-objects" (dict
* nested objects, so we have to call it again. "this_object" $item
*/ "additional_objects" $additional_objects
{{ $item = partial "json-schema/resolve-allof" $item }}
{{ $additional_objects = partial "json-schema/resolve-additional-types" (dict
"schema" $item
"anchor_base" $anchor_base "anchor_base" $anchor_base
"name" (printf "%s.oneOf[%d]" $name $idx)) "name" (printf "%s.oneOf[%d]" $name $idx)
}} ) }}
{{ end }} {{ end }}
{{ end }} {{ end }}