Skip to content

Commit fa9224d

Browse files
authored
Merge pull request #732 from MeastroZI/main2
Tests for dependentSchema and propertyDependencies with unevaluatedPro…
2 parents 64a3e7b + 83bedd5 commit fa9224d

7 files changed

+269
-1
lines changed

tests/draft-next/additionalProperties.json

+68
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,73 @@
176176
"valid": false
177177
}
178178
]
179+
},
180+
{
181+
"description": "propertyDependencies with additionalProperties",
182+
"schema": {
183+
"$schema": "https://json-schema.org/draft/next/schema",
184+
"properties" : {"foo2" : {}},
185+
"propertyDependencies": {
186+
"foo" : {},
187+
"foo2": {
188+
"bar": {
189+
"properties": {
190+
"buz": {}
191+
}
192+
}
193+
}
194+
},
195+
"additionalProperties": false
196+
},
197+
"tests": [
198+
{
199+
"description": "additionalProperties doesn't consider propertyDependencies properties" ,
200+
"data": {"foo": ""},
201+
"valid": false
202+
},
203+
{
204+
"description": "additionalProperties can't see buz even when foo2 is present",
205+
"data": {"foo2": "bar", "buz": ""},
206+
"valid": false
207+
},
208+
{
209+
"description": "additionalProperties can't see buz",
210+
"data": {"buz": ""},
211+
"valid": false
212+
}
213+
]
214+
},
215+
{
216+
"description": "dependentSchemas with additionalProperties",
217+
"schema": {
218+
"$schema": "https://json-schema.org/draft/next/schema",
219+
"properties": {"foo2": {}},
220+
"dependentSchemas": {
221+
"foo": {},
222+
"foo2": {
223+
"properties": {
224+
"bar": {}
225+
}
226+
}
227+
},
228+
"additionalProperties": false
229+
},
230+
"tests": [
231+
{
232+
"description": "additionalProperties doesn't consider dependentSchemas",
233+
"data": {"foo": ""},
234+
"valid": false
235+
},
236+
{
237+
"description": "additionalProperties can't see bar",
238+
"data": {"bar": ""},
239+
"valid": false
240+
},
241+
{
242+
"description": "additionalProperties can't see bar even when foo2 is present",
243+
"data": {"foo2": "", "bar": ""},
244+
"valid": false
245+
}
246+
]
179247
}
180248
]

tests/draft-next/unevaluatedProperties.json

+69
Original file line numberDiff line numberDiff line change
@@ -1603,5 +1603,74 @@
16031603
"valid": false
16041604
}
16051605
]
1606+
},
1607+
{
1608+
"description": "propertyDependencies with unevaluatedProperties" ,
1609+
"schema" : {
1610+
"$schema": "https://json-schema.org/draft/next/schema",
1611+
"properties" : {"foo2" : {}},
1612+
"propertyDependencies": {
1613+
"foo" : {},
1614+
"foo2": {
1615+
"bar": {
1616+
"properties": {
1617+
"buz": {}
1618+
}
1619+
}
1620+
}
1621+
},
1622+
"unevaluatedProperties": false
1623+
},
1624+
1625+
"tests": [
1626+
{
1627+
"description": "unevaluatedProperties doesn't consider propertyDependencies" ,
1628+
"data": {"foo": "bar"},
1629+
"valid": false
1630+
},
1631+
{
1632+
"description": "unevaluatedProperties sees buz when foo2 is present",
1633+
"data": {"foo2": "bar", "buz": ""},
1634+
"valid": true
1635+
},
1636+
{
1637+
"description": "unevaluatedProperties doesn't see buz when foo2 is absent",
1638+
"data": {"buz": ""},
1639+
"valid": false
1640+
}
1641+
]
1642+
},
1643+
{
1644+
"description": "dependentSchemas with unevaluatedProperties",
1645+
"schema": {
1646+
"$schema": "https://json-schema.org/draft/next/schema",
1647+
"properties": {"foo2": {}},
1648+
"dependentSchemas": {
1649+
"foo" : {},
1650+
"foo2": {
1651+
"properties": {
1652+
"bar":{}
1653+
}
1654+
}
1655+
},
1656+
"unevaluatedProperties": false
1657+
},
1658+
"tests": [
1659+
{
1660+
"description": "unevaluatedProperties doesn't consider dependentSchemas",
1661+
"data": {"foo": ""},
1662+
"valid": false
1663+
},
1664+
{
1665+
"description": "unevaluatedProperties doesn't see bar when foo2 is absent",
1666+
"data": {"bar": ""},
1667+
"valid": false
1668+
},
1669+
{
1670+
"description": "unevaluatedProperties sees bar when foo2 is present",
1671+
"data": {"foo2": "", "bar": ""},
1672+
"valid": true
1673+
}
1674+
]
16061675
}
16071676
]

tests/draft2019-09/additionalProperties.json

+33
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,38 @@
176176
"valid": false
177177
}
178178
]
179+
},
180+
{
181+
"description": "dependentSchemas with additionalProperties",
182+
"schema": {
183+
"$schema": "https://json-schema.org/draft/2019-09/schema",
184+
"properties": {"foo2": {}},
185+
"dependentSchemas": {
186+
"foo" : {},
187+
"foo2": {
188+
"properties": {
189+
"bar":{}
190+
}
191+
}
192+
},
193+
"additionalProperties": false
194+
},
195+
"tests": [
196+
{
197+
"description": "additionalProperties doesn't consider dependentSchemas",
198+
"data": {"foo": ""},
199+
"valid": false
200+
},
201+
{
202+
"description": "additionalProperties can't see bar",
203+
"data": {"bar": ""},
204+
"valid": false
205+
},
206+
{
207+
"description": "additionalProperties can't see bar even when foo2 is present",
208+
"data": { "foo2": "", "bar": ""},
209+
"valid": false
210+
}
211+
]
179212
}
180213
]

tests/draft2019-09/unevaluatedProperties.json

+33
Original file line numberDiff line numberDiff line change
@@ -1567,5 +1567,38 @@
15671567
"valid": false
15681568
}
15691569
]
1570+
},
1571+
{
1572+
"description": "dependentSchemas with unevaluatedProperties",
1573+
"schema": {
1574+
"$schema": "https://json-schema.org/draft/2019-09/schema",
1575+
"properties": {"foo2": {}},
1576+
"dependentSchemas": {
1577+
"foo" : {},
1578+
"foo2": {
1579+
"properties": {
1580+
"bar":{}
1581+
}
1582+
}
1583+
},
1584+
"unevaluatedProperties": false
1585+
},
1586+
"tests": [
1587+
{
1588+
"description": "unevaluatedProperties doesn't consider dependentSchemas",
1589+
"data": {"foo": ""},
1590+
"valid": false
1591+
},
1592+
{
1593+
"description": "unevaluatedProperties doesn't see bar when foo2 is absent",
1594+
"data": {"bar": ""},
1595+
"valid": false
1596+
},
1597+
{
1598+
"description": "unevaluatedProperties sees bar when foo2 is present",
1599+
"data": { "foo2": "", "bar": ""},
1600+
"valid": true
1601+
}
1602+
]
15701603
}
15711604
]

tests/draft2020-12/additionalProperties.json

+33
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,38 @@
182182
"valid": false
183183
}
184184
]
185+
},
186+
{
187+
"description": "dependentSchemas with additionalProperties",
188+
"schema": {
189+
"$schema": "https://json-schema.org/draft/2020-12/schema",
190+
"properties": {"foo2": {}},
191+
"dependentSchemas": {
192+
"foo" : {},
193+
"foo2": {
194+
"properties": {
195+
"bar": {}
196+
}
197+
}
198+
},
199+
"additionalProperties": false
200+
},
201+
"tests": [
202+
{
203+
"description": "additionalProperties doesn't consider dependentSchemas",
204+
"data": {"foo": ""},
205+
"valid": false
206+
},
207+
{
208+
"description": "additionalProperties can't see bar",
209+
"data": {"bar": ""},
210+
"valid": false
211+
},
212+
{
213+
"description": "additionalProperties can't see bar even when foo2 is present",
214+
"data": {"foo2": "", "bar": ""},
215+
"valid": false
216+
}
217+
]
185218
}
186219
]

tests/draft2020-12/unevaluatedItems.json

-1
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,6 @@
793793
"data": [ "b" ],
794794
"valid": false
795795
}
796-
797796
]
798797
}
799798
]

tests/draft2020-12/unevaluatedProperties.json

+33
Original file line numberDiff line numberDiff line change
@@ -1564,5 +1564,38 @@
15641564
"valid": false
15651565
}
15661566
]
1567+
},
1568+
{
1569+
"description": "dependentSchemas with unevaluatedProperties",
1570+
"schema": {
1571+
"$schema": "https://json-schema.org/draft/2020-12/schema",
1572+
"properties": {"foo2": {}},
1573+
"dependentSchemas": {
1574+
"foo" : {},
1575+
"foo2": {
1576+
"properties": {
1577+
"bar":{}
1578+
}
1579+
}
1580+
},
1581+
"unevaluatedProperties": false
1582+
},
1583+
"tests": [
1584+
{
1585+
"description": "unevaluatedProperties doesn't consider dependentSchemas",
1586+
"data": {"foo": ""},
1587+
"valid": false
1588+
},
1589+
{
1590+
"description": "unevaluatedProperties doesn't see bar when foo2 is absent",
1591+
"data": {"bar": ""},
1592+
"valid": false
1593+
},
1594+
{
1595+
"description": "unevaluatedProperties sees bar when foo2 is present",
1596+
"data": { "foo2": "", "bar": ""},
1597+
"valid": true
1598+
}
1599+
]
15671600
}
15681601
]

0 commit comments

Comments
 (0)