ajv-validator / ajv-validator/ajv-cli

Support YAML CustomTags

未關閉
#127 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
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 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。