support for multi-document yaml in openapi2jsonschema

This commit is contained in:
Yann Hamon 2020-12-28 11:08:05 +01:00
parent 509ad8e997
commit f6e6f7584c

View file

@ -98,7 +98,12 @@ for crdFile in sys.argv[1:]:
else: else:
f = open(crdFile) f = open(crdFile)
with f: with f:
y = yaml.load(f, Loader=yaml.SafeLoader) for y in yaml.load_all(f, Loader=yaml.SafeLoader):
if "kind" not in y:
continue
if y["kind"] != "CustomResourceDefinition":
continue
filename = "" filename = ""
schemaJSON = "" schemaJSON = ""
if "spec" in y and "validation" in y["spec"] and "openAPIV3Schema" in y["spec"]["validation"]: if "spec" in y and "validation" in y["spec"] and "openAPIV3Schema" in y["spec"]["validation"]: