Skip to content

Commit

Permalink
Merge pull request #30 from zaninime/allow-int-string
Browse files Browse the repository at this point in the history
Handle a specific case of anyOf
  • Loading branch information
arnarg authored Jan 4, 2025
2 parents 18219e7 + 76333f5 commit a6fd2eb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkgs/generators/crd2jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ def flatten_ref(definition, key, root=True):
if 'type' in definition and definition['type'] == 'object':
if not 'properties' in definition:
if 'additionalProperties' in definition:
# The nix generator doesn't support anyOf
if 'anyOf' in definition['additionalProperties']:
definition['additionalProperties'] = definition['additionalProperties']['anyOf'][0]
if definition['additionalProperties'].get('x-kubernetes-int-or-string', False):
# Patch the definition based on the custom x-kubernetes-int-or-string
definition['additionalProperties'] = { 'type': 'string', 'format': 'int-or-string' }
else:
# The nix generator doesn't support anyOf
definition['additionalProperties'] = definition['additionalProperties']['anyOf'][0]

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

0 comments on commit a6fd2eb

Please sign in to comment.