Skip to content

Commit 72023e6

Browse files
committed
encoding/jsonschema: add if/then/else test
This allows us to see the schema that results from an "if" keyword, so we can see the improvement in the next CL. Signed-off-by: Roger Peppe <[email protected]> Change-Id: I23ace058b944ab6362ee0c119a7c476bb9e5f10a Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202608 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
1 parent 2c6ed18 commit 72023e6

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
-- schema.json --
2+
{
3+
"$schema": "https://json-schema.org/draft/2019-09/schema",
4+
"if": {
5+
"properties": {
6+
"a": {
7+
"type": "number"
8+
}
9+
},
10+
"required": [
11+
"a"
12+
]
13+
},
14+
"then": {
15+
"properties": {
16+
"b": {
17+
"type": "number"
18+
}
19+
},
20+
"required": [
21+
"b"
22+
]
23+
},
24+
"type": "object"
25+
}
26+
-- out/decode/extract --
27+
@jsonschema(schema="https://json-schema.org/draft/2019-09/schema")
28+
matchIf(null | bool | number | string | [...] | {
29+
a!: number
30+
...
31+
}, null | bool | number | string | [...] | {
32+
b!: number
33+
...
34+
}, _) & {
35+
...
36+
}

0 commit comments

Comments
 (0)