From 9228dba9155a6d58222f76dd27a7942f4462c3df Mon Sep 17 00:00:00 2001 From: Patrick Ruckstuhl Date: Sat, 25 Sep 2021 01:09:08 +0200 Subject: [PATCH] Also support items elements in yaml, e.g. for kubectl get crds -o yaml --- scripts/openapi2jsonschema.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/openapi2jsonschema.py b/scripts/openapi2jsonschema.py index bfaba37..51b90dc 100755 --- a/scripts/openapi2jsonschema.py +++ b/scripts/openapi2jsonschema.py @@ -113,14 +113,20 @@ for crdFile in sys.argv[1:]: else: f = open(crdFile) with f: + defs = [] for y in yaml.load_all(f, Loader=yaml.SafeLoader): if y is None: continue + if "items" in y: + defs.extend(y["items"]) if "kind" not in y: continue if y["kind"] != "CustomResourceDefinition": continue + else: + defs.append(y) + for y in defs: filename_format = os.getenv("FILENAME_FORMAT", "{kind}_{version}") filename = "" if "spec" in y and "validation" in y["spec"] and "openAPIV3Schema" in y["spec"]["validation"]: