From eeed25046b189924fe835ab784eadbb241ae574c Mon Sep 17 00:00:00 2001 From: Lars Kellogg-Stedman Date: Fri, 22 Oct 2021 11:37:25 -0400 Subject: [PATCH] Avoid KeyError when attempting to access "properties" key Closes #54 --- openapi2jsonschema/command.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openapi2jsonschema/command.py b/openapi2jsonschema/command.py index 9cd1bfc..1fd7083 100644 --- a/openapi2jsonschema/command.py +++ b/openapi2jsonschema/command.py @@ -94,6 +94,10 @@ def default(output, schema, prefix, stand_alone, expanded, kubernetes, strict): # For Kubernetes, populate `apiVersion` and `kind` properties from `x-kubernetes-group-version-kind` for type_name in definitions: type_def = definitions[type_name] + if "properties" not in type_def: + error(f"{type_name} has no properties") + continue + if "x-kubernetes-group-version-kind" in type_def: for kube_ext in type_def["x-kubernetes-group-version-kind"]: if expanded and "apiVersion" in type_def["properties"]: