Skip to content

Commit

Permalink
Avoid KeyError when attempting to access "properties" key
Browse files Browse the repository at this point in the history
  • Loading branch information
larsks authored and tricktron committed Jan 31, 2023
1 parent b0480c1 commit 2c6b259
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openapi2jsonschema/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down

0 comments on commit 2c6b259

Please sign in to comment.