helm-schema icon indicating copy to clipboard operation
helm-schema copied to clipboard

Feat: support custom annotations

Open chivalryq opened this issue 1 year ago • 2 comments

Overview

Support custom annotations. See https://json-schema.org/blog/posts/custom-annotations-will-continue

After generation: custom annotation starts with "x-" will be added to field.

Source

# @schema
# type: string
# x-foo-type: modelWeight
# @schema
modelWeight: ""

result

{
    "modelWeight": {
      "default": "",
      "title": "modelWeight",
      "type": "string",
      "x-foo-field-type": "modelWeight"
    }
}

chivalryq avatar Aug 08 '24 11:08 chivalryq

Hi @chivalryq,

thanks for your PR. Looks interesting, do you have any specific usecase in mind? I'd like to understand better what is used for :)

dadav avatar Aug 08 '24 17:08 dadav

Hi @dadav

We are using helm-based ArgoCD application, and we build a platform helping us to dispatch those apps. When filling values of applications, there're fields like:

modelWeight: <series>/<version>/<weight>

where series, version, weight are metadata that stored in system. So we can make it a "Custom" field in frontend form instead of a simple string field.

image

Here's the trick, we can use a custom annotation to mark what this field type should be at frontend. And generate schema from it.

# @schema
# x-<company-name>/field-type: model-weight
# @schema
modelWeight: ""

chivalryq avatar Aug 09 '24 03:08 chivalryq

Why not :)

dadav avatar Aug 31 '24 17:08 dadav