-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathyaml_schema.txtar
More file actions
57 lines (50 loc) · 1.34 KB
/
yaml_schema.txtar
File metadata and controls
57 lines (50 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# YAML with schema comment validates against local schema
exec validator valid.yaml
stdout '✓'
# YAML with invalid data fails schema validation
! exec validator invalid.yaml
stdout '×'
stdout 'error:'
# YAML without schema comment passes (syntax only)
exec validator plain.yaml
stdout '✓'
# YAML without schema + --require-schema fails
! exec validator --require-schema plain.yaml
stdout '×'
stdout 'no schema declared'
# YAML with schema + --require-schema passes
exec validator --require-schema valid.yaml
stdout '✓'
# YAML with schema comment after content line is ignored (no schema)
exec validator comment_after_content.yaml
stdout '✓'
# That same file fails with --require-schema
! exec validator --require-schema comment_after_content.yaml
stdout 'no schema declared'
-- schema.json --
{
"type": "object",
"required": ["host", "port"],
"properties": {
"host": { "type": "string" },
"port": { "type": "integer" },
"debug": { "type": "boolean" }
},
"additionalProperties": false
}
-- valid.yaml --
# yaml-language-server: $schema=schema.json
host: localhost
port: 5432
debug: true
-- invalid.yaml --
# yaml-language-server: $schema=schema.json
host: localhost
port: not_a_number
-- plain.yaml --
host: localhost
port: 5432
-- comment_after_content.yaml --
host: localhost
# yaml-language-server: $schema=schema.json
port: 5432