Skip to content

Commit 5e2845c

Browse files
authored
Merge pull request #668 from hauner/if-without-then-else-creates-annotations
test if without then/else creates annotations
2 parents 987a4c8 + c1fae00 commit 5e2845c

File tree

6 files changed

+159
-0
lines changed

6 files changed

+159
-0
lines changed

tests/draft-next/unevaluatedItems.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,5 +692,28 @@
692692
"valid": true
693693
}
694694
]
695+
},
696+
{
697+
"description": "unevaluatedItems can see annotations from if without then and else",
698+
"schema": {
699+
"$schema": "https://json-schema.org/draft/next/schema",
700+
"if": {
701+
"prefixItems": [{"const": "a"}]
702+
},
703+
"unevaluatedItems": false
704+
},
705+
"tests": [
706+
{
707+
"description": "valid in case if is evaluated",
708+
"data": [ "a" ],
709+
"valid": true
710+
},
711+
{
712+
"description": "invalid in case if is evaluated",
713+
"data": [ "b" ],
714+
"valid": false
715+
}
716+
717+
]
695718
}
696719
]

tests/draft-next/unevaluatedProperties.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,5 +1538,35 @@
15381538
"valid": false
15391539
}
15401540
]
1541+
},
1542+
{
1543+
"description": "unevaluatedProperties can see annotations from if without then and else",
1544+
"schema": {
1545+
"$schema": "https://json-schema.org/draft/next/schema",
1546+
"if": {
1547+
"patternProperties": {
1548+
"foo": {
1549+
"type": "string"
1550+
}
1551+
}
1552+
},
1553+
"unevaluatedProperties": false
1554+
},
1555+
"tests": [
1556+
{
1557+
"description": "valid in case if is evaluated",
1558+
"data": {
1559+
"foo": "a"
1560+
},
1561+
"valid": true
1562+
},
1563+
{
1564+
"description": "invalid in case if is evaluated",
1565+
"data": {
1566+
"bar": "a"
1567+
},
1568+
"valid": false
1569+
}
1570+
]
15411571
}
15421572
]

tests/draft2019-09/unevaluatedItems.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,5 +600,28 @@
600600
"valid": true
601601
}
602602
]
603+
},
604+
{
605+
"description": "unevaluatedItems can see annotations from if without then and else",
606+
"schema": {
607+
"$schema": "https://json-schema.org/draft/2019-09/schema",
608+
"if": {
609+
"items": [{"const": "a"}]
610+
},
611+
"unevaluatedItems": false
612+
},
613+
"tests": [
614+
{
615+
"description": "valid in case if is evaluated",
616+
"data": [ "a" ],
617+
"valid": true
618+
},
619+
{
620+
"description": "invalid in case if is evaluated",
621+
"data": [ "b" ],
622+
"valid": false
623+
}
624+
625+
]
603626
}
604627
]

tests/draft2019-09/unevaluatedProperties.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,5 +1441,35 @@
14411441
"valid": false
14421442
}
14431443
]
1444+
},
1445+
{
1446+
"description": "unevaluatedProperties can see annotations from if without then and else",
1447+
"schema": {
1448+
"$schema": "https://json-schema.org/draft/2019-09/schema",
1449+
"if": {
1450+
"patternProperties": {
1451+
"foo": {
1452+
"type": "string"
1453+
}
1454+
}
1455+
},
1456+
"unevaluatedProperties": false
1457+
},
1458+
"tests": [
1459+
{
1460+
"description": "valid in case if is evaluated",
1461+
"data": {
1462+
"foo": "a"
1463+
},
1464+
"valid": true
1465+
},
1466+
{
1467+
"description": "invalid in case if is evaluated",
1468+
"data": {
1469+
"bar": "a"
1470+
},
1471+
"valid": false
1472+
}
1473+
]
14441474
}
14451475
]

tests/draft2020-12/unevaluatedItems.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,5 +692,28 @@
692692
"valid": true
693693
}
694694
]
695+
},
696+
{
697+
"description": "unevaluatedItems can see annotations from if without then and else",
698+
"schema": {
699+
"$schema": "https://json-schema.org/draft/2020-12/schema",
700+
"if": {
701+
"prefixItems": [{"const": "a"}]
702+
},
703+
"unevaluatedItems": false
704+
},
705+
"tests": [
706+
{
707+
"description": "valid in case if is evaluated",
708+
"data": [ "a" ],
709+
"valid": true
710+
},
711+
{
712+
"description": "invalid in case if is evaluated",
713+
"data": [ "b" ],
714+
"valid": false
715+
}
716+
717+
]
695718
}
696719
]

tests/draft2020-12/unevaluatedProperties.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,5 +1441,35 @@
14411441
"valid": false
14421442
}
14431443
]
1444+
},
1445+
{
1446+
"description": "unevaluatedProperties can see annotations from if without then and else",
1447+
"schema": {
1448+
"$schema": "https://json-schema.org/draft/2020-12/schema",
1449+
"if": {
1450+
"patternProperties": {
1451+
"foo": {
1452+
"type": "string"
1453+
}
1454+
}
1455+
},
1456+
"unevaluatedProperties": false
1457+
},
1458+
"tests": [
1459+
{
1460+
"description": "valid in case if is evaluated",
1461+
"data": {
1462+
"foo": "a"
1463+
},
1464+
"valid": true
1465+
},
1466+
{
1467+
"description": "invalid in case if is evaluated",
1468+
"data": {
1469+
"bar": "a"
1470+
},
1471+
"valid": false
1472+
}
1473+
]
14441474
}
14451475
]

0 commit comments

Comments
 (0)