bitnami / readme-generator-for-helm

Auto generate READMEs for Helm Charts
https://bitnami.com
Apache License 2.0
212 stars 48 forks source link

Allow values with `null` values during the schema generation #31

Closed antgamdia closed 2 years ago

antgamdia commented 2 years ago

Context: json-schema does not apply any restrictions on the default field, but openapi schema does. Specifically, they say "the value MUST conform to the defined type for the Schema Object".

I assume this is the reason why this check is there. However, if the nullable: true is passed, the null value is allowed. Spec here. Issue here

Shouldn't we just add nullable: true when a null property is detected? At least, I don't think we should throw an error.

Example:

## @section kubeappsapis parameters
kubeappsapis:
  pluginConfig:
    kappController:
      packages:
        v1alpha1:
          ## @param kubeappsapis.pluginConfig.kappController.packages.v1alpha1.defaultPrereleasesVersionSelection Default policy for allowing prereleases containing one of the identifiers
          ## ref: https://carvel.dev/kapp-controller/docs/latest/package-consumer-concepts/#prereleases
          ## e.g:
          # defaultPrereleasesVersionSelection: 
          # - rc
          defaultPrereleasesVersionSelection: null
{
  name: 'kubeappsapis.pluginConfig.kappController.packages.v1alpha1.defaultPrereleasesVersionSelection',
  value: 'null',
  description: 'Default policy for allowing prereleases containing one of the identifiers',
  section: 'kubeappsapis parameters',
  type: 'object',
  nullable: true
}
miguelaeh commented 2 years ago

Thank you @antgamdia for reporting this.

I think we can move the check of the null parameters to the metadata checks and allow setting null as a value. The error was set for the case in which there is not a default value at all on one property but looks like for some reason null is also considered as if there were no value.