summaryrefslogtreecommitdiff
path: root/json/tests/draft4/additionalItems.json
blob: 784bc8461058a84f1b393e1fdbcae8e6b2cd8617 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
[
    {
        "description": "additionalItems as schema",
        "schema": {
            "items": [{}],
            "additionalItems": {"type": "integer"}
        },
        "tests": [
            {
                "description": "additional items match schema",
                "data": [ null, 2, 3, 4 ],
                "valid": true
            },
            {
                "description": "additional items do not match schema",
                "data": [ null, 2, 3, "foo" ],
                "valid": false
            }
        ]
    },
    {
        "description": "when items is schema, additionalItems does nothing",
        "schema": {
            "items": {},
            "additionalItems": false
        },
        "tests": [
            {
                "description": "all items match schema",
                "data": [ 1, 2, 3, 4, 5 ],
                "valid": true
            }
        ]
    },
    {
        "description": "array of items with no additionalItems permitted",
        "schema": {
            "items": [{}, {}, {}],
            "additionalItems": false
        },
        "tests": [
            {
                "description": "empty array",
                "data": [ ],
                "valid": true
            },
            {
                "description": "fewer number of items present (1)",
                "data": [ 1 ],
                "valid": true
            },
            {
                "description": "fewer number of items present (2)",
                "data": [ 1, 2 ],
                "valid": true
            },
            {
                "description": "equal number of items present",
                "data": [ 1, 2, 3 ],
                "valid": true
            },
            {
                "description": "additional items are not permitted",
                "data": [ 1, 2, 3, 4 ],
                "valid": false
            }
        ]
    },
    {
        "description": "additionalItems as false without items",
        "schema": {"additionalItems": false},
        "tests": [
            {
                "description":
                    "items defaults to empty schema so everything is valid",
                "data": [ 1, 2, 3, 4, 5 ],
                "valid": true
            },
            {
                "description": "ignores non-arrays",
                "data": {"foo" : "bar"},
                "valid": true
            }
        ]
    },
    {
        "description": "additionalItems are allowed by default",
        "schema": {"items": [{"type": "integer"}]},
        "tests": [
            {
                "description": "only the first item is validated",
                "data": [1, "foo", false],
                "valid": true
            }
        ]
    },
    {
        "description": "additionalItems should not look in applicators, valid case",
        "schema": {
            "allOf": [
                { "items": [ { "type": "integer" } ] }
            ],
            "additionalItems": { "type": "boolean" }
        },
        "tests": [
            {
                "description": "items defined in allOf are not examined",
                "data": [ 1, null ],
                "valid": true
            }
        ]
    },
    {
        "description": "additionalItems should not look in applicators, invalid case",
        "schema": {
            "allOf": [
                { "items": [ { "type": "integer" }, { "type": "string" } ] }
            ],
            "items": [ {"type": "integer" } ],
            "additionalItems": { "type": "boolean" }
        },
        "tests": [
            {
                "description": "items defined in allOf are not examined",
                "data": [ 1, "hello" ],
                "valid": false
            }
        ]
    },
    {
        "description": "items validation adjusts the starting index for additionalItems",
        "schema": {
            "items": [ { "type": "string" } ],
            "additionalItems": { "type": "integer" }
        },
        "tests": [
            {
                "description": "valid items",
                "data": [ "x", 2, 3 ],
                "valid": true
            },
            {
                "description": "wrong type of second item",
                "data": [ "x", "y" ],
                "valid": false
            }
        ]
    }
]