Skip to content

Commit 8e2668b

Browse files
marcarnarg
authored andcommitted
fix: handling of additionalProperties in JSON schema generation
1 parent 2f40fbb commit 8e2668b

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

pkgs/generators/crd2jsonschema.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,20 @@ def flatten_ref(definition, key, root=True):
100100
if "type" in definition and definition["type"] == "object":
101101
if "properties" not in definition:
102102
if "additionalProperties" in definition:
103-
if "anyOf" in definition["additionalProperties"]:
104-
if definition["additionalProperties"].get(
105-
"x-kubernetes-int-or-string", False
106-
):
107-
# Patch the definition based on the custom x-kubernetes-int-or-string
108-
definition["additionalProperties"] = {
109-
"type": "string",
110-
"format": "int-or-string",
111-
}
112-
else:
113-
# The nix generator doesn't support anyOf
114-
definition["additionalProperties"] = definition[
115-
"additionalProperties"
116-
]["anyOf"][0]
103+
if definition["additionalProperties"].get(
104+
"x-kubernetes-int-or-string", False
105+
):
106+
# Patch the definition based on the custom x-kubernetes-int-or-string
107+
definition["additionalProperties"] = {
108+
"type": "string",
109+
"format": "int-or-string",
110+
}
111+
elif "anyOf" in definition["additionalProperties"]:
112+
# The nix generator doesn't support anyOf
113+
definition["additionalProperties"] = definition[
114+
"additionalProperties"
115+
]["anyOf"][0]
116+
117117

118118
# If additionalProperties only contains 'x-kubernetes-preserve-unknown-fields'
119119
# we can just drop the `additionalProperties` entirely and the generator

0 commit comments

Comments
 (0)