Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle a specific case of anyOf #30

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading