xref: /aosp_15_r20/external/json-schema-validator/src/test/suite/tests/draft3/additionalProperties.json (revision 78c4dd6aa35290980cdcd1623a7e337e8d021c7c)
1[
2    {
3        "description":
4            "additionalProperties being false does not allow other properties",
5        "schema": {
6            "properties": {"foo": {}, "bar": {}},
7            "patternProperties": { "^v": {} },
8            "additionalProperties": false
9        },
10        "tests": [
11            {
12                "description": "no additional properties is valid",
13                "data": {"foo": 1},
14                "valid": true
15            },
16            {
17                "description": "an additional property is invalid",
18                "data": {"foo" : 1, "bar" : 2, "quux" : "boom"},
19                "valid": false
20            },
21            {
22                "description": "ignores arrays",
23                "data": [1, 2, 3],
24                "valid": true
25            },
26            {
27                "description": "ignores strings",
28                "data": "foobarbaz",
29                "valid": true
30            },
31            {
32                "description": "ignores other non-objects",
33                "data": 12,
34                "valid": true
35            },
36            {
37                "description": "patternProperties are not additional properties",
38                "data": {"foo":1, "vroom": 2},
39                "valid": true
40            }
41        ]
42    },
43    {
44        "description": "non-ASCII pattern with additionalProperties",
45        "schema": {
46            "patternProperties": {"^á": {}},
47            "additionalProperties": false
48        },
49        "tests": [
50            {
51                "description": "matching the pattern is valid",
52                "data": {"ármányos": 2},
53                "valid": true
54            },
55            {
56                "description": "not matching the pattern is invalid",
57                "data": {"élmény": 2},
58                "valid": false
59            }
60        ]
61    },
62    {
63        "description": "additionalProperties with schema",
64        "schema": {
65            "properties": {"foo": {}, "bar": {}},
66            "additionalProperties": {"type": "boolean"}
67        },
68        "tests": [
69            {
70                "description": "no additional properties is valid",
71                "data": {"foo": 1},
72                "valid": true
73            },
74            {
75                "description": "an additional valid property is valid",
76                "data": {"foo" : 1, "bar" : 2, "quux" : true},
77                "valid": true
78            },
79            {
80                "description": "an additional invalid property is invalid",
81                "data": {"foo" : 1, "bar" : 2, "quux" : 12},
82                "valid": false
83            }
84        ]
85    },
86    {
87        "description":
88            "additionalProperties can exist by itself",
89        "schema": {
90            "additionalProperties": {"type": "boolean"}
91        },
92        "tests": [
93            {
94                "description": "an additional valid property is valid",
95                "data": {"foo" : true},
96                "valid": true
97            },
98            {
99                "description": "an additional invalid property is invalid",
100                "data": {"foo" : 1},
101                "valid": false
102            }
103        ]
104    },
105    {
106        "description": "additionalProperties are allowed by default",
107        "schema": {"properties": {"foo": {}, "bar": {}}},
108        "tests": [
109            {
110                "description": "additional properties are allowed",
111                "data": {"foo": 1, "bar": 2, "quux": true},
112                "valid": true
113            }
114        ]
115    },
116    {
117        "description": "additionalProperties does not look in applicators",
118        "schema": {
119            "extends": [
120                {"properties": {"foo": {}}}
121            ],
122            "additionalProperties": {"type": "boolean"}
123        },
124        "tests": [
125            {
126                "description": "properties defined in extends are not examined",
127                "data": {"foo": 1, "bar": true},
128                "valid": false
129            }
130        ]
131    },
132    {
133        "description": "additionalProperties with null valued instance properties",
134        "schema": {
135            "additionalProperties": {
136                "type": "null"
137            }
138        },
139        "tests": [
140            {
141                "description": "allows null values",
142                "data": {"foo": null},
143                "valid": true
144            }
145        ]
146    }
147]
148