Repository navigation
Expand file tree
/
Copy pathdependent-required.t
More file actions
169 lines (154 loc) · 4.22 KB
/
Copy pathdependent-required.t
File metadata and controls
169 lines (154 loc) · 4.22 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env ys-0
use ys::taptest: :all
test::
- name: import-compact-dependencies
cmnd: bin/ysd -t ysd -
stdi: |
{
"type": "object",
"properties": {
"first": {"type": "string"},
"second": {"type": "integer"}
},
"dependentRequired": {
"first": ["second", "third"],
"second": []
}
}
want: |
# Converted from JSON Schema
.open: true
first?: +Str :need(second,third)
second?: +Int :need()
- name: export-compact-dependencies
cmnd: |
sh -c '
bin/ysd -t jsc -C - |
jq -c ".required, .dependentRequired, .additionalProperties"
'
stdi: |
first: +Str :need(second,third)
second?: +Int :need()
want: |
["first"]
{"first":["second","third"],"second":[]}
false
- name: import-explicit-complex-dependency
cmnd: bin/ysd -t ysd -
stdi: |
{
"type": "object",
"properties": {"first": {"type": "string"}},
"dependentRequired": {"first": ["a b", "other"]}
}
want: |
# Converted from JSON Schema
.open: true
first?:
.type: +Str
.need: [a b, other]
- name: export-explicit-complex-dependency
cmnd: |
sh -c '
bin/ysd -t jsc -C - |
jq -c ".dependentRequired"
'
stdi: |
first?:
.type: +Str
.need: [a b, other]
want: |
{"first":["a b","other"]}
- name: nested-dependency-roundtrip
cmnd: sh -c 'bin/ysd -Rq - && echo OK'
stdi: |
{
"type": "object",
"properties": {
"nested": {
"type": "object",
"properties": {"trigger": {"type": "integer"}},
"dependentRequired": {
"trigger": ["a b", "undeclared-target"]
}
}
},
"additionalProperties": false
}
want: |
OK
- name: address-roundtrip
cmnd: >-
sh -c 'bin/ysd -Rq
www/docs/assets/editor/examples/address.schema.json && echo OK'
want: |
OK
- name: reject-undeclared-trigger
cmnd: |
sh -c '
bin/ysd -t ysd - 2>&1 |
perl -ne "print if $. == 1"
printf "%s\n" \
"{\"type\":\"object\",\"dependentRequired\":{\"missing\":[]}}" |
bin/ysd -t ysd - 2>&1 |
perl -ne "print if $. == 1"
'
stdi: |
{
"type": "object",
"properties": {"declared": {"type": "string"}},
"dependentRequired": {"missing": ["declared"]}
}
want: |
ysd: dependentRequired trigger has no property declaration: missing
ysd: dependentRequired trigger has no property declaration: missing
- name: reject-invalid-json-dependencies
cmnd: |
sh -c '
for value in true "[1]" "[\"same\",\"same\"]"; do
printf "%s\n" \
"{\"type\":\"object\",\"properties\":{\"key\":{}},"\
"\"dependentRequired\":{\"key\":$value}}" |
bin/ysd -t ysd - 2>&1 |
perl -ne "print if $. == 1"
done
'
want: |
ysd: yamlschema .need requires a sequence of property names
ysd: yamlschema .need property names must be strings
ysd: yamlschema .need property names must be unique
- name: reject-invalid-ysd-dependencies
cmnd: |
sh -c '
for value in true "[1]" "[same, same]"; do
printf "key:\n .type: +Str\n .need: %s\n" "$value" |
bin/ysd -t jsc -C - 2>&1 |
perl -ne "print if $. == 1"
done
'
want: |
ysd: yamlschema .need requires a sequence of property names
ysd: yamlschema .need property names must be strings
ysd: yamlschema .need property names must be unique
- name: reject-malformed-and-misplaced-need
cmnd: |
sh -c '
printf "key: +Str :need(a,,b)\n" |
bin/ysd -t jsc -C - 2>&1 |
perl -ne "print if $. == 1"
printf "key: +Str need:a\n" |
bin/ysd -t jsc -C - 2>&1 |
perl -ne "print if $. == 1"
printf ".need: [key]\n" |
bin/ysd -t jsc -C - 2>&1 |
perl -ne "print if $. == 1"
printf "+Type:\n .type: +Str\n .need: [key]\n" |
bin/ysd -t jsc -C - 2>&1 |
perl -ne "print if $. == 1"
'
want: |
ysd: invalid yamlschema need clause: :need(a,,b)
ysd: unsupported yamlschema keyword: need; use :need(...)
ysd: yamlschema .need is only valid on a property definition
ysd: yamlschema .need is only valid on a property definition
done: