Repository navigation
Expand file tree
/
Copy pathpassthrough.t
More file actions
161 lines (152 loc) · 5.15 KB
/
Copy pathpassthrough.t
File metadata and controls
161 lines (152 loc) · 5.15 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
#!/usr/bin/env ys-0
use ys::taptest: :all
test::
- name: json-schema-passthrough-warnings-and-ysd-data
cmnd: sh -c 'bin/ysd -f jsc -t ysd - 2>&1'
stdi: |
{
"type": "object",
"properties": {
"price": {
"type": "number",
"multipleOf": 0.5,
"exclusiveMinimum": 0
},
"choice": {
"if": {
"properties": {
"kind": {"format": "uuid"}
}
},
"then": {"required": ["value"]}
}
},
"additionalProperties": false
}
want: |
ysd: warning: unsupported JSON Schema keyword "multipleOf" at /properties/price/multipleOf
ysd: warning: unsupported JSON Schema keyword "exclusiveMinimum" at /properties/price/exclusiveMinimum
ysd: warning: unsupported JSON Schema keyword "if" at /properties/choice/if
ysd: warning: unsupported JSON Schema keyword "format" at /properties/choice/if/properties/kind/format
ysd: warning: unsupported JSON Schema keyword "then" at /properties/choice/then
# Converted from JSON Schema
price?:
.type: +Num
.multipleOf: 0.5
.exclusiveMinimum: 0
choice?:
.if:
properties:
kind:
format: uuid
.then:
required:
- value
- name: json-schema-to-ysdc-preserves-passthrough-without-yaml-reload
cmnd: sh -c 'bin/ysd -f jsc -t ysdc -J -C - 2>&1'
stdi: |
{
"type": "object",
"properties": {
"price": {"type": "number", "multipleOf": 0.5}
},
"additionalProperties": false
}
want: |
ysd: warning: unsupported JSON Schema keyword "multipleOf" at /properties/price/multipleOf
{"price?":{".type":"+Num",".multipleOf":0.5}}
- name: passthrough-roundtrip-from-expanded-yaml
cmnd: sh -c 'bin/ysd -f ysdc -t jsc -C - 2>&1'
stdi: |
price?:
.type: +Num
.multipleOf: 0.5
.exclusiveMinimum: 0
choice?:
.if:
properties:
kind:
format: uuid
.then:
required: [value]
want: |
ysd: warning: unsupported JSON Schema keyword "multipleOf" at /properties/price/multipleOf
ysd: warning: unsupported JSON Schema keyword "exclusiveMinimum" at /properties/price/exclusiveMinimum
ysd: warning: unsupported JSON Schema keyword "if" at /properties/choice/if
ysd: warning: unsupported JSON Schema keyword "format" at /properties/choice/if/properties/kind/format
ysd: warning: unsupported JSON Schema keyword "then" at /properties/choice/then
{"$schema":"https:\/\/json-schema.org\/draft\/2020-12\/schema","type":"object","additionalProperties":false,"properties":{"price":{"type":"number","exclusiveMinimum":0,"multipleOf":0.5},"choice":{"if":{"properties":{"kind":{"format":"uuid"}}},"then":{"required":["value"]}}}}
- name: passthrough-array-and-item-keywords-stay-at-their-levels
cmnd: |
sh -c '
set -eu
tmp=$(mktemp -d)
trap "rm -r \"$tmp\"" EXIT
cat > "$tmp/in.schema.json"
bin/ysd -f jsc -t ysdc "$tmp/in.schema.json" \
> "$tmp/out.ysdc.yaml" 2> "$tmp/import.warn"
bin/ysd -f ysdc -t jsc -C "$tmp/out.ysdc.yaml" \
> "$tmp/out.schema.json" 2> "$tmp/export.warn"
cat "$tmp/import.warn"
cat "$tmp/out.ysdc.yaml"
cat "$tmp/export.warn"
ys -pe "ARGS.0:read:json/load == select-keys( \
ARGS.1:read:json/load ARGS.0:read:json/load:keys)" \
-- "$tmp/in.schema.json" "$tmp/out.schema.json"
'
stdi: |
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"emails": {
"type": "array",
"items": {"type": "string", "format": "email"},
"contains": {"type": "string"},
"minContains": 1
}
},
"additionalProperties": false
}
want: |
ysd: warning: unsupported JSON Schema keyword "contains" at /properties/emails/contains
ysd: warning: unsupported JSON Schema keyword "minContains" at /properties/emails/minContains
emails?:
.list: +JSON-Schema/email
.contains:
type: string
.minContains: 1
ysd: warning: unsupported JSON Schema keyword "contains" at /properties/emails/contains
ysd: warning: unsupported JSON Schema keyword "minContains" at /properties/emails/minContains
true
- name: passthrough-warning-paths-escape-json-pointer-and-repeat
cmnd: sh -c 'bin/ysd -f jsc -t ysd - 2>&1'
stdi: |
{
"type": "object",
"properties": {
"a/b~c": {"multipleOf": 2},
"other": {"multipleOf": 3}
},
"additionalProperties": false
}
want: |
ysd: warning: unsupported JSON Schema keyword "multipleOf" at /properties/a~1b~0c/multipleOf
ysd: warning: unsupported JSON Schema keyword "multipleOf" at /properties/other/multipleOf
# Converted from JSON Schema
a/b~c?:
.multipleOf: 2
other?:
.multipleOf: 3
- name: unknown-dotted-directive-is-still-an-error
cmnd: |
sh -c '
output=$(printf "field:\n .formt: email\n" |
bin/ysd -f ysd -t ysdc - 2>&1)
status=$?
test "$status" -eq 2
printf "%s\n" "$output" | sed -n 1p
'
want: |
ysd: unsupported yamlschema directive: .formt
done: