Skip to content

Schema conversion conflates "optional field" with "allowing null values" #44

Description

@jcmcken

Similar issue was reported here but this might be a better home for it, not sure.

In this code the tool conflates an optional field (i.e. a field that does not have to be specified) with a field that allows null values. But this is not correct and these are distinct things in some cases (e.g. Kubernetes schemas)

As a real world example, if you have a Kubernetes Deployment and set a secret volume like this (with secretName having the null value)...

...
spec:
  volumes:
    - name: somevol
      secret:
        secretName:
...

The schema produced from openapi2jsonschema using kubeval will happily consider this config valid. But if you try to apply the config using kubectl or kustomize, it complains that secretName cannot take a null value. And indeed if you look at the upstream schema, nowhere does it specify that the field is nullable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions