Skip to content

Commit 0bd8619

Browse files
committed
encoding/jsonschema: add test cases for nested values
The current `state.value` logic looks wrong: it sets the `allowedTypes` value recursively when it encounters a structured value such as an array or an object even though only the top level of the value should influence the allowed types. As it happens, the fact that `usedTypes` is set at the same time hides this error, and it _seems_ that no other test fails as a result. However, upcoming changes will reveal this shortcoming, so we add a couple of test cases to show the fix. Signed-off-by: Roger Peppe <[email protected]> Change-Id: I85173a321d3578094fc96f5b56ed6269c496c18c Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199399 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 7ca1a14 commit 0bd8619

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- type.json --
2+
{
3+
"type": "array",
4+
"const": [
5+
1
6+
]
7+
}
8+
9+
-- out/decode/cue --
10+
[1]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
-- type.json --
3+
{
4+
"type": "object",
5+
"const": {"a": 1}
6+
}
7+
8+
-- out/decode/cue --
9+
a: 1
10+
...

0 commit comments

Comments
 (0)