losisin / helm-values-schema-json

Helm plugin for generating values.schema.json from multiple values files
MIT License
64 stars 9 forks source link

Add: option to apply enum on array items #74

Closed juanmesa-jt closed 3 months ago

juanmesa-jt commented 3 months ago

This commit introduces a new feature that allows specifying enum values for array items in the JSON schema using the itemEnum annotation.

Changes:

With this feature, users can now define enum values for array items in their YAML files using the itemEnum annotation, and the generated JSON schema will include the enum values within the items section.

Example:

# values.yaml
capacityType: ["one","two"] # @schema type:[array];default:["one","two"];minItems:1;itemEnum:["one","two"]

Generated JSON for this value will look like

"capacityType": {
    "default": [
        "one",
        "two"
    ],
    "items": {
        "type": "string",
        "enum": [
            "one",
            "two"
        ]
    },
    "minItems": 1,
    "type": [
        "array"
    ]
}
codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.98%. Comparing base (15584b9) to head (4106fe3). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #74 +/- ## ========================================== + Coverage 98.97% 98.98% +0.01% ========================================== Files 6 6 Lines 390 394 +4 ========================================== + Hits 386 390 +4 Misses 2 2 Partials 2 2 ``` | [Flag](https://app.codecov.io/gh/losisin/helm-values-schema-json/pull/74/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Aleksandar+Stojanov) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/losisin/helm-values-schema-json/pull/74/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Aleksandar+Stojanov) | `98.98% <100.00%> (+0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Aleksandar+Stojanov#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

juanmesa-jt commented 3 months ago

I'd be happy to merge this if you can also update the docs

Docs updated.