Skip to content

Commit

Permalink
encoding/jsonschema: add if/then/else test
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rogpeppe committed Oct 15, 2024
1 parent 2c6ed18 commit 72023e6
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions encoding/jsonschema/testdata/txtar/ifthenelse.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-- schema.json --
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"if": {
"properties": {
"a": {
"type": "number"
}
},
"required": [
"a"
]
},
"then": {
"properties": {
"b": {
"type": "number"
}
},
"required": [
"b"
]
},
"type": "object"
}
-- out/decode/extract --
@jsonschema(schema="https://json-schema.org/draft/2019-09/schema")
matchIf(null | bool | number | string | [...] | {
a!: number
...
}, null | bool | number | string | [...] | {
b!: number
...
}, _) & {
...
}

0 comments on commit 72023e6

Please sign in to comment.