Skip to content

Add more json schema features - #10

Merged
Miosp merged 5 commits into
masterfrom
add-more-jsonchema-stuff
Jul 16, 2026
Merged

Miosp merged 5 commits into
masterfrom
add-more-jsonchema-stuff

Conversation

@Miosp

@Miosp Miosp commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a batch of extended draft-07 JSON Schema keyword directives to helm-scribe.
Each is written as an @-directive in a values.yaml comment, parsed onto the
value node, and emitted into the generated schema.

New directives:

Directive Applies to Emits
@format <name> string format
@minLength / @maxLength <int> string minLength / maxLength
@minItems / @maxItems <int> array minItems / maxItems
@uniqueItems array uniqueItems
@const <scalar> scalar const
@title <text> any title
@additionalProperties true|false object additionalProperties
@optional any omits field from required

Behavior notes

  • Round-trip invariant is preserved: any single-value or bound constraint
    (const, uniqueItems, min/maxLength, min/maxItems, ...) that the
    chart's own bundled default would violate is dropped at emit time and warned
    about at parse time, so the generated schema never rejects the values it
    ships with.
  • @const + @enum on the same key is a hard generation error (contradictory).
  • On Kubernetes-typed nodes these keywords are stripped with a warning ($ref
    ignores sibling keywords).
  • Keywords are gated by base type: string-only keywords are dropped on
    non-strings, item-count keywords on non-arrays, @additionalProperties on
    non-objects — each with a warning.

Miosp added 3 commits July 16, 2026 21:53
Carry format, min/max length, min/max items, uniqueItems, const, title,
additionalProperties and optional on ValueNode so the parser can attach the
extended draft-07 keyword directives and the schema layer can emit them.
Add @Format, @minlength, @maxlength, @minItems, @Maxitems, @Uniqueitems,
@const, @title, @additionalProperties and @optional to the annotation parser,
wire them onto each node, and cross-check them at parse time: warn on
duplicates and bad arguments, on constraints attached to Kubernetes types, on
@additionalProperties misuse, and when a bundled default cannot satisfy @const
(equality mirrors the schema layer so the warning fires exactly when the
emitter drops the constraint).
Emit the new keywords gated by base type, reject contradictory @const with
@enum, and relax any single-value or bound constraint (const, uniqueItems,
min/max length, min/max items) that the chart's own bundled default would
violate so the generated schema never rejects the values it ships with.
@Miosp Miosp self-assigned this Jul 16, 2026
Comment thread parser/annotations.go Fixed
Miosp and others added 2 commits July 16, 2026 22:06
… between integer types'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@Miosp
Miosp merged commit b6bc136 into master Jul 16, 2026
9 checks passed
@Miosp
Miosp deleted the add-more-jsonchema-stuff branch July 16, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants