fix: Propagate root schema annotations and definitions from subschemas #162
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
First of all, thank you for a very nice helm tool!
I've added some changes, mainly in propagating definitions from external schemas and root schema annotations to parent schemas. This ensures that
@schema.rootannotations and$defs/definitionsfrom external schema files work correctly in generated JSON schemas. I also see that Helm v3.18.0 (https://github.com/helm/helm/releases/tag/v3.18.0) added support for JSON Schema 2020, so perhaps I'll look into that some time.I also merged #155 into this fork.
Changes
1. Definitions Propagation from Dependencies (
cmd/helm-schema/main.go)Merge
$defsanddefinitionsfrom dependency chart schemas into parent chart schemas:$defs(Draft-07+) anddefinitions(legacy) keywords2. Root Schema Annotations Propagation (
pkg/schema/schema.go)Complete propagation of all root schema fields from
contentSchemato document-level schema:Previously, these fields were being extracted from
@schema.rootcomments but not copied to the final schema object.3. Comprehensive Test Coverage (
pkg/schema/root_schema_test.go)Added 13 new tests across 3 test functions:
$defsanddefinitionskeywords)definitionsvs$defsbased on reference style.Root Schema Annotations
Users can now use all
@schema.rootannotation fields:External Schema References with Definitions
Definitions from external schema files are properly collected and merged:
All definitions from common-schemas.json will appear in the generated schema's $defs or definitions section, making the schema self-contained and valid.
Dependency Schema Merging
When processing chart dependencies, definitions from dependency schemas are now propagated to parent charts, enabling proper schema composition across chart hierarchies. The name of the definition will be overwritten by the last who defined it. This can be problematic if you have equally named definitions across several subcharts.