Repository navigation
Expand file tree
/
Copy pathtypes.t
More file actions
174 lines (157 loc) · 4.59 KB
/
Copy pathtypes.t
File metadata and controls
174 lines (157 loc) · 4.59 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
170
171
172
173
174
#!/usr/bin/env ys-0
use ys::taptest: :all
test::
- name: types
cmnd: bin/ysd -t ysd -
stdi: |
{
"properties": {
"s": {"type": "string"},
"i": {"type": "integer"},
"n": {"type": "number"},
"b": {"type": "boolean"}
},
"required": ["s", "i", "n", "b"]
}
want: |
# Converted from JSON Schema
.open: true
s: +Str
i: +Int
n: +Num
b: +Bool
- name: nullable-pattern
cmnd: bin/ysd -f jsc -t ysd -
stdi: |
{
"type": "object",
"properties": {
"testsuite": {
"type": ["string", "null"],
"pattern": "^[\\p{Word} _*.+-]+$",
"description": "Optional test suite name"
}
}
}
want: |
# Converted from JSON Schema
.open: true
testsuite?: +Str~ ~"[\p{Word} _*.+-]+" -"Optional test suite name"
- name: unconstrained-and-closed-schemas
cmnd: bin/ysd -f jsc -t ysd -
stdi: |
{
"type": "object",
"properties": {
"anything": {},
"closed": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
}
want: |
# Converted from JSON Schema
anything?: +Any
closed?: {}
- name: unconstrained-schema-roundtrip
cmnd: bin/ysd -R -f jsc -
stdi: |
{
"type": "object",
"properties": {
"default": {}
},
"additionalProperties": false
}
want: |
OK
- name: true-schema
cmnd: bin/ysd -f jsc -t ysd -
stdi: |
true
want: |
# Converted from JSON Schema
.root: +Any
- name: false-schema
cmnd: bin/ysd -f jsc -t ysd -
stdi: |
false
want: |
# Converted from JSON Schema
.root: +Not(+Any)
- name: yaml-number-inference
cmnd: bin/ysd -t ysdc -J -C -
stdi: |
float: 1.5
float-enum:
.enum: [1.5, 2.5]
mixed-enum:
.enum: [1, 2.5]
fractional-range: 0.5..1
integer-range: 0..1
want: |
{"float":{".type":"+Float",".const":1.5},"float-enum":{".type":"+Float",".enum":[1.5,2.5]},"mixed-enum":{".type":"+Num",".enum":[1,2.5]},"fractional-range":{".type":"+Num",".range":[0.5,1]},"integer-range":{".type":"+Int",".range":[0,1]}}
- name: json-number-inference
cmnd: bin/ysd -t ysd -
stdi: |
{
"properties": {
"decimal": {"enum": [1.5, 2.5]},
"mixed": {"enum": [1, 2.5]},
"constant": {"const": 1.5}
},
"required": ["decimal", "mixed", "constant"]
}
want: |
# Converted from JSON Schema
.open: true
decimal: +Num [1.5, 2.5]
mixed: +Num [1, 2.5]
constant: +Num ==1.5
- name: float-export-warning
cmnd: sh -c 'bin/ysd -f ysd -t jsc -C - 2>&1'
stdi: |
+measurement: +Float
number: +Num
float: +Float
floats: +Float[]
choice: +One(+Int,+Float)
nested:
reading?: +Float
want: |
ysd: warning: +Float at /$defs/measurement exports as JSON Schema "number", which also accepts integers
ysd: warning: +Float at /properties/float exports as JSON Schema "number", which also accepts integers
ysd: warning: +Float at /properties/floats/items exports as JSON Schema "number", which also accepts integers
ysd: warning: +Float at /properties/choice/oneOf/1 exports as JSON Schema "number", which also accepts integers
ysd: warning: +Float at /properties/nested/properties/reading exports as JSON Schema "number", which also accepts integers
{"$schema":"https:\/\/json-schema.org\/draft\/2020-12\/schema","type":"object","additionalProperties":false,"required":["number","float","floats","choice","nested"],"$defs":{"measurement":{"type":"number"}},"properties":{"number":{"type":"number"},"float":{"type":"number"},"floats":{"type":"array","items":{"type":"number"}},"choice":{"oneOf":[{"type":"integer"},{"type":"number"}]},"nested":{"type":"object","additionalProperties":false,"properties":{"reading":{"type":"number"}}}}}
- name: reject-unknown-capitalized-type-references
cmnd: |
sh -c '
for value in \
"+Stx" \
"+Stx[]" \
"+Map{+Stx}" \
"+One(+Str,+Stx)"; do
printf "value: %s\n" "$value" |
bin/ysd -f ysd -t jsc - 2>&1 |
perl -ne "print if \$. == 1"
done
'
want: |
ysd: unknown yamlschema built-in type: +Stx
ysd: unknown yamlschema built-in type: +Stx
ysd: unknown yamlschema built-in type: +Stx
ysd: unknown yamlschema built-in type: +Stx
- name: reject-malformed-plus-prefixed-type
cmnd: |
sh -c '
printf "value: +Stx(\n" |
bin/ysd -f ysd -t jsc - 2>&1 |
perl -ne "print if \$. == 1"
'
want: |
ysd: invalid yamlschema type expression: +Stx(
done: