`$def`s from `$ref`ed schema do not get propagated
I have a key in my values that is used to construct a Pydantic BaseModel for the python service that my Helm chart deploys. Due to some easy to miss mistakes in whitespace, I wanted helm template to be able to catch these.
My values.yaml has this key
# @schema
# $ref: config_schema.json
# @schema
# -- Config for the worker goes here, will be mounted into a config file
worker:
api:
# -- 0.0.0.0 required to allow non-loopback traffic
# If using hostNetwork, the port must be free on the host
url: http://0.0.0.0:8000/
And config_schema.json has the following:
{
"$defs": {
"RestConfig": {
"additionalProperties": false,
"properties": {
"url": {
"default": "http://localhost:8000/",
"format": "uri",
"maxLength": 2083,
"minLength": 1,
"title": "Url",
"type": "string"
}
},
"title": "RestConfig",
"type": "object"
},
},
"additionalProperties": false,
"description": "Config for the worker application as a whole. Root of\nconfig tree.",
"properties": {
"api": {
"$ref": "#/$defs/RestConfig"
}
},
"title": "ApplicationConfig",
"type": "object"
}
But when my values.schema.json is generated:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"worker": {
"additionalProperties": false,
"description": "Config for the worker application as a whole. Root of\nconfig tree.",
"properties": {
"api": {
"$ref": "#/$defs/RestConfig",
"required": []
}
},
"required": [],
"title": "ApplicationConfig",
"type": "object"
}
},
"required": [],
"type": "object"
}
$ helm template chart/
Error: values don't meet the specifications of the schema(s) in the following chart(s):
chart:
Object has no key '$defs'
I believe the fix may be adding $def as a field to the Schema struct?
https://github.com/dadav/helm-schema/blob/eb9f8017306302ce6debe7dcc41ab7a5deac970c/pkg/schema/schema.go#L221
Defs map[string]*Schema `yaml:"$defs,omitempty" json:"$defs,omitempty"`
?
i do believe nested "$ref" statements are suffering from the same issue.
(referencing a schema definition, which references another in the same schema)