merge-schema.py: traverse anyOf/oneOf/allOf sub schemas

Properly compile alternative sub schemas to ensure that schema references
are properly substituted.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich
2021-05-15 17:05:47 +02:00
committed by John Crispin
parent 7072d2949f
commit 1fda79f088

View File

@@ -36,6 +36,13 @@ def schema_compile(input, output, definitions, tiny):
output["$ref"] = "#/$defs/{}".format(name)
elif k == "$ref" and not tiny:
output["properties"] = {"reference": {"type": "string"}}
elif k == "anyOf" or k == "oneOf" or k == "allOf":
r = []
for v in input[k]:
o = {}
schema_compile(v, o, definitions, tiny)
r.append(o)
output[k] = r
else:
output[k] = input[k]
return output