instrumenta / instrumenta/openapi2jsonschema
Schema conversion conflates "optional field" with "allowing null values"
- Dominant language
- Python
- Stars
- 248
- Forks
- 95
- PR merge metrics
- No merged PRs in 30d
Description
Similar issue was reported [here](https://github.com/instrumenta/kubernetes-json-schema/issues/25) but this might be a better home for it, not sure.
In [this code](https://github.com/instrumenta/openapi2jsonschema/blob/master/openapi2jsonschema/util.py#L69) 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)...
```yaml
...
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.