Skip to content

Commit a7e4c44

Browse files
shin19991207datho7561
authored andcommitted
Support return types for yaml.customTags
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
1 parent 045b21f commit a7e4c44

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The following settings are supported:
5252
* `yaml.schemas`: Helps you associate schemas with files in a glob pattern
5353
* `yaml.schemaStore.enable`: When set to true, the YAML language server will pull in all available schemas from [JSON Schema Store](http://schemastore.org/)
5454
* `yaml.schemaStore.url`: URL of a schema store catalog to use when downloading schemas.
55-
* `yaml.customTags`: Array of custom tags that the parser will validate against. It has two ways to be used. Either an item in the array is a custom tag such as "!Ref" and it will automatically map !Ref to a scalar, or you can specify the type of the object !Ref should be, e.g. "!Ref sequence". The type of object can be either scalar (for strings and booleans), sequence (for arrays), mapping (for objects).
55+
* `yaml.customTags`: Array of custom tags that the parser will validate against. It has three ways to be used. A tag without a type, such as "!Ref", is treated as a scalar tag. A tag with a node type, such as "!Ref sequence", specifies the YAML node type that the tag is written on. A tag with a node type and return type, such as "!FindInMap sequence:string", also specifies the schema type that the tagged value evaluates to. Supported node types are scalar, sequence, and mapping. Supported return types are string, number, integer, boolean, null, array, and object. The return type aliases scalar, sequence, and mapping are accepted as string, array, and object.
5656
* `yaml.maxItemsComputed`: The maximum number of outline symbols and folding regions computed (limited for performance reasons).
5757
* `yaml.disableDefaultProperties`: Disable adding not required properties with default values into completion text (default is false).
5858
* `yaml.suggest.parentSkeletonSelectedFirst`: If true, the user must select some parent skeleton first before autocompletion starts to suggest the rest of the properties. When the YAML object is not empty, autocompletion ignores this setting and returns all properties and skeletons.
@@ -105,11 +105,13 @@ To use the custom tags in your YAML file, you need to first specify the custom t
105105
"yaml.customTags": [
106106
"!Scalar-example scalar",
107107
"!Seq-example sequence",
108-
"!Mapping-example mapping"
108+
"!Mapping-example mapping",
109+
"!Seq-as-string-example sequence:string"
109110
]
110111
```
111112

112-
The !Scalar-example would map to a scalar custom tag, the !Seq-example would map to a sequence custom tag, the !Mapping-example would map to a mapping custom tag.
113+
The !Scalar-example would map to a scalar custom tag, the !Seq-example would map to a sequence custom tag, and the !Mapping-example would map to a mapping custom tag.
114+
The !Seq-as-string-example would map to a sequence custom tag, and the whole tagged value would be treated as a string during schema validation.
113115

114116
You can then use the newly defined custom tags inside the YAML file:
115117

@@ -121,6 +123,9 @@ some_sequence: !Seq-example
121123
some_mapping: !Mapping-example
122124
some_mapping_key_1: some_mapping_value_1
123125
some_mapping_key_2: some_mapping_value_2
126+
some_string: !Seq-as-string-example
127+
- value_1
128+
- value_2
124129
```
125130
126131
## Associating schemas

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
"yaml.customTags": {
226226
"type": "array",
227227
"default": [],
228-
"description": "Custom tags for the parser to use"
228+
"description": "Custom tags for the parser to use. Supported formats are \"!Tag\" for a scalar tag, \"!Tag nodeType\" to specify the YAML node type, and \"!Tag nodeType:returnType\" to specify both the YAML node type and the schema type the tagged value evaluates to."
229229
},
230230
"yaml.schemaStore.enable": {
231231
"type": "boolean",

0 commit comments

Comments
 (0)