Feat: support custom annotations
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"
}
}
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 :)
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.
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: ""
Why not :)