ajv-validator / ajv-validator/ajv-cli
Support YAML CustomTags
- 主要语言
- TypeScript
- 星标
- 316
- 派生
- 77
- PR 合并指标
- 30 天内没有已合并 PR
描述
Thank you very much for all your work
It would be nice to have an option to support custom tags in yaml. Tags in yaml can have one of 3 kinds: scalar, sequence, or mapping. I would like to have an option to add a list of custom tags and the kind of the type.
https://yaml.org/spec/1.2/spec.html#kind//
I found in the underlaying js-yang lib an example:
https://github.com/nodeca/js-yaml/blob/master/examples/custom_types.yml
```
subject: Custom types in JS-YAML
spaces:
- !space
height: 1000
width: 1000
points:
- !point [ 10, 43, 23 ]
- !point [ 165, 0, 50 ]
- !point [ 100, 100, 100 ]
```
https://github.com/nodeca/js-yaml/blob/master/examples/custom_types.js
I think for the validation we only would need the definition of the kind and add it as a schema. I was hoping something like this would do it.
```
new jsyaml.Type('!Space', { kind: 'mapping' });
````
I use manly VS Code with the YAML extension (yaml-language-server) and maybe it is possible to use the same format.
https://github.com/redhat-developer/yaml-language-server#adding-custom-tags
```
"yaml.customTags": [
"!Scalar-example scalar",
"!Seq-example sequence",
"!Mapping-example mapping"
]
```
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。