1[ 2 { 3 "description": "a schema given for items", 4 "schema": { 5 "items": {"type": "integer"} 6 }, 7 "tests": [ 8 { 9 "description": "valid items", 10 "data": [ 1, 2, 3 ], 11 "valid": true 12 }, 13 { 14 "description": "wrong type of items", 15 "data": [1, "x"], 16 "valid": false 17 }, 18 { 19 "description": "ignores non-arrays", 20 "data": {"foo" : "bar"}, 21 "valid": true 22 }, 23 { 24 "description": "JavaScript pseudo-array is valid", 25 "data": { 26 "0": "invalid", 27 "length": 1 28 }, 29 "valid": true 30 } 31 ] 32 }, 33 { 34 "description": "an array of schemas for items", 35 "schema": { 36 "items": [ 37 {"type": "integer"}, 38 {"type": "string"} 39 ] 40 }, 41 "tests": [ 42 { 43 "description": "correct types", 44 "data": [ 1, "foo" ], 45 "valid": true 46 }, 47 { 48 "description": "wrong types", 49 "data": [ "foo", 1 ], 50 "valid": false 51 }, 52 { 53 "description": "incomplete array of items", 54 "data": [ 1 ], 55 "valid": true 56 }, 57 { 58 "description": "array with additional items", 59 "data": [ 1, "foo", true ], 60 "valid": true 61 }, 62 { 63 "description": "empty array", 64 "data": [ ], 65 "valid": true 66 }, 67 { 68 "description": "JavaScript pseudo-array is valid", 69 "data": { 70 "0": "invalid", 71 "1": "valid", 72 "length": 2 73 }, 74 "valid": true 75 } 76 ] 77 }, 78 { 79 "description": "items and subitems", 80 "schema": { 81 "definitions": { 82 "item": { 83 "type": "array", 84 "additionalItems": false, 85 "items": [ 86 { "$ref": "#/definitions/sub-item" }, 87 { "$ref": "#/definitions/sub-item" } 88 ] 89 }, 90 "sub-item": { 91 "type": "object", 92 "required": ["foo"] 93 } 94 }, 95 "type": "array", 96 "additionalItems": false, 97 "items": [ 98 { "$ref": "#/definitions/item" }, 99 { "$ref": "#/definitions/item" }, 100 { "$ref": "#/definitions/item" } 101 ] 102 }, 103 "tests": [ 104 { 105 "description": "valid items", 106 "data": [ 107 [ {"foo": null}, {"foo": null} ], 108 [ {"foo": null}, {"foo": null} ], 109 [ {"foo": null}, {"foo": null} ] 110 ], 111 "valid": true 112 }, 113 { 114 "description": "too many items", 115 "data": [ 116 [ {"foo": null}, {"foo": null} ], 117 [ {"foo": null}, {"foo": null} ], 118 [ {"foo": null}, {"foo": null} ], 119 [ {"foo": null}, {"foo": null} ] 120 ], 121 "valid": false 122 }, 123 { 124 "description": "too many sub-items", 125 "data": [ 126 [ {"foo": null}, {"foo": null}, {"foo": null} ], 127 [ {"foo": null}, {"foo": null} ], 128 [ {"foo": null}, {"foo": null} ] 129 ], 130 "valid": false 131 }, 132 { 133 "description": "wrong item", 134 "data": [ 135 {"foo": null}, 136 [ {"foo": null}, {"foo": null} ], 137 [ {"foo": null}, {"foo": null} ] 138 ], 139 "valid": false 140 }, 141 { 142 "description": "wrong sub-item", 143 "data": [ 144 [ {}, {"foo": null} ], 145 [ {"foo": null}, {"foo": null} ], 146 [ {"foo": null}, {"foo": null} ] 147 ], 148 "valid": false 149 }, 150 { 151 "description": "fewer items is valid", 152 "data": [ 153 [ {"foo": null} ], 154 [ {"foo": null} ] 155 ], 156 "valid": true 157 } 158 ] 159 }, 160 { 161 "description": "nested items", 162 "schema": { 163 "type": "array", 164 "items": { 165 "type": "array", 166 "items": { 167 "type": "array", 168 "items": { 169 "type": "array", 170 "items": { 171 "type": "number" 172 } 173 } 174 } 175 } 176 }, 177 "tests": [ 178 { 179 "description": "valid nested array", 180 "data": [[[[1]], [[2],[3]]], [[[4], [5], [6]]]], 181 "valid": true 182 }, 183 { 184 "description": "nested array with invalid type", 185 "data": [[[["1"]], [[2],[3]]], [[[4], [5], [6]]]], 186 "valid": false 187 }, 188 { 189 "description": "not deep enough", 190 "data": [[[1], [2],[3]], [[4], [5], [6]]], 191 "valid": false 192 } 193 ] 194 }, 195 { 196 "description": "items with null instance elements", 197 "schema": { 198 "items": { 199 "type": "null" 200 } 201 }, 202 "tests": [ 203 { 204 "description": "allows null elements", 205 "data": [ null ], 206 "valid": true 207 } 208 ] 209 }, 210 { 211 "description": "array-form items with null instance elements", 212 "schema": { 213 "items": [ 214 { 215 "type": "null" 216 } 217 ] 218 }, 219 "tests": [ 220 { 221 "description": "allows null elements", 222 "data": [ null ], 223 "valid": true 224 } 225 ] 226 } 227] 228