ajv-validator / ajv-validator/ajv-cli

Support YAML CustomTags

Aperta
#127 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
316
Fork
77
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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"
]
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.