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

openapi2jsonschema.py silently fails when using "version" instead of "versions" #159

Open
michohl opened this issue Dec 27, 2022 · 0 comments

Comments

@michohl
Copy link

michohl commented Dec 27, 2022

When running openapi2jsonschema.py on a CRD that doesn't contain a versions key it will silently fail.

I'm using the following as an example (referred to as test.yml)

apiVersion: example.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: foo.bar.io
  annotations:
    "helm.sh/resource-policy": keep
spec:
  group: asdf.io
  version: v1
  scope: Namespaced
  names:
    plural: foos
    singular: foo
    kind: Foo
    shortNames:
    - fo

If I run the script with this file I get the following behavior:

(.venv) $ ./kubeconform/scripts/openapi2jsonschema.py test.yml
(.venv) $ echo $?
0

I believe this is caused by our spec above not including a versions key since it's using version instead. So it fails out of the original if condition but it is also not using validation so we fail the elif condition as well which means we end up doing nothing with the entire file.

I'm hoping either openapi2jsonschema.py could be modified to respect a singular version as specified in my example or if that is not possible then at least the script will present an error and a non-zero exit code for the user.

@michohl michohl changed the title openapi2json.py silently fails when using "version" instead of "versions" openapi2jsonschema.py silently fails when using "version" instead of "versions" Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant