cuelang.org/go@v0.13.0/encoding/jsonschema/testdata/external/tests/draft7/items.json (about) 1 [ 2 { 3 "description": "a schema given for items", 4 "schema": { 5 "items": { 6 "type": "integer" 7 } 8 }, 9 "tests": [ 10 { 11 "description": "valid items", 12 "data": [ 13 1, 14 2, 15 3 16 ], 17 "valid": true 18 }, 19 { 20 "description": "wrong type of items", 21 "data": [ 22 1, 23 "x" 24 ], 25 "valid": false 26 }, 27 { 28 "description": "ignores non-arrays", 29 "data": { 30 "foo": "bar" 31 }, 32 "valid": true 33 }, 34 { 35 "description": "JavaScript pseudo-array is valid", 36 "data": { 37 "0": "invalid", 38 "length": 1 39 }, 40 "valid": true 41 } 42 ] 43 }, 44 { 45 "description": "an array of schemas for items", 46 "schema": { 47 "items": [ 48 { 49 "type": "integer" 50 }, 51 { 52 "type": "string" 53 } 54 ] 55 }, 56 "tests": [ 57 { 58 "description": "correct types", 59 "data": [ 60 1, 61 "foo" 62 ], 63 "valid": true 64 }, 65 { 66 "description": "wrong types", 67 "data": [ 68 "foo", 69 1 70 ], 71 "valid": false 72 }, 73 { 74 "description": "incomplete array of items", 75 "data": [ 76 1 77 ], 78 "valid": true, 79 "skip": { 80 "v2": "5 errors in empty disjunction:\nconflicting values [1] and {...} (mismatched types list and struct):\n generated.cue:2:1\n generated.cue:2:54\n instance.json:1:1\nconflicting values bool and [1] (mismatched types bool and list):\n generated.cue:2:8\n instance.json:1:1\nconflicting values null and [1] (mismatched types null and list):\n generated.cue:2:1\n instance.json:1:1\nconflicting values number and [1] (mismatched types number and list):\n generated.cue:2:15\n instance.json:1:1\nconflicting values string and [1] (mismatched types string and list):\n generated.cue:2:24\n instance.json:1:1\n", 81 "v3": "6 errors in empty disjunction:\nconflicting values [1] and bool (mismatched types list and bool):\n generated.cue:2:8\n instance.json:1:1\nconflicting values [1] and null (mismatched types list and null):\n generated.cue:2:1\n instance.json:1:1\nconflicting values [1] and number (mismatched types list and number):\n generated.cue:2:15\n instance.json:1:1\nconflicting values [1] and string (mismatched types list and string):\n generated.cue:2:24\n instance.json:1:1\nconflicting values [1] and {...} (mismatched types list and struct):\n generated.cue:2:54\n instance.json:1:1\nincompatible list lengths (1 and 3):\n generated.cue:2:33\n" 82 } 83 }, 84 { 85 "description": "array with additional items", 86 "data": [ 87 1, 88 "foo", 89 true 90 ], 91 "valid": true 92 }, 93 { 94 "description": "empty array", 95 "data": [], 96 "valid": true, 97 "skip": { 98 "v2": "5 errors in empty disjunction:\nconflicting values [] and {...} (mismatched types list and struct):\n generated.cue:2:1\n generated.cue:2:54\n instance.json:1:1\nconflicting values bool and [] (mismatched types bool and list):\n generated.cue:2:8\n instance.json:1:1\nconflicting values null and [] (mismatched types null and list):\n generated.cue:2:1\n instance.json:1:1\nconflicting values number and [] (mismatched types number and list):\n generated.cue:2:15\n instance.json:1:1\nconflicting values string and [] (mismatched types string and list):\n generated.cue:2:24\n instance.json:1:1\n", 99 "v3": "6 errors in empty disjunction:\nconflicting values [] and bool (mismatched types list and bool):\n generated.cue:2:8\n instance.json:1:1\nconflicting values [] and null (mismatched types list and null):\n generated.cue:2:1\n instance.json:1:1\nconflicting values [] and number (mismatched types list and number):\n generated.cue:2:15\n instance.json:1:1\nconflicting values [] and string (mismatched types list and string):\n generated.cue:2:24\n instance.json:1:1\nconflicting values [] and {...} (mismatched types list and struct):\n generated.cue:2:54\n instance.json:1:1\nincompatible list lengths (0 and 3):\n generated.cue:2:33\n" 100 } 101 }, 102 { 103 "description": "JavaScript pseudo-array is valid", 104 "data": { 105 "0": "invalid", 106 "1": "valid", 107 "length": 2 108 }, 109 "valid": true 110 } 111 ] 112 }, 113 { 114 "description": "items with boolean schema (true)", 115 "schema": { 116 "items": true 117 }, 118 "tests": [ 119 { 120 "description": "any array is valid", 121 "data": [ 122 1, 123 "foo", 124 true 125 ], 126 "valid": true 127 }, 128 { 129 "description": "empty array is valid", 130 "data": [], 131 "valid": true 132 } 133 ] 134 }, 135 { 136 "description": "items with boolean schema (false)", 137 "schema": { 138 "items": false 139 }, 140 "tests": [ 141 { 142 "description": "any non-empty array is invalid", 143 "data": [ 144 1, 145 "foo", 146 true 147 ], 148 "valid": false 149 }, 150 { 151 "description": "empty array is valid", 152 "data": [], 153 "valid": true 154 } 155 ] 156 }, 157 { 158 "description": "items with boolean schemas", 159 "schema": { 160 "items": [ 161 true, 162 false 163 ] 164 }, 165 "tests": [ 166 { 167 "description": "array with one item is valid", 168 "data": [ 169 1 170 ], 171 "valid": true, 172 "skip": { 173 "v2": "5 errors in empty disjunction:\nconflicting values [1] and {...} (mismatched types list and struct):\n generated.cue:2:1\n generated.cue:2:49\n instance.json:1:1\nconflicting values bool and [1] (mismatched types bool and list):\n generated.cue:2:8\n instance.json:1:1\nconflicting values null and [1] (mismatched types null and list):\n generated.cue:2:1\n instance.json:1:1\nconflicting values number and [1] (mismatched types number and list):\n generated.cue:2:15\n instance.json:1:1\nconflicting values string and [1] (mismatched types string and list):\n generated.cue:2:24\n instance.json:1:1\n", 174 "v3": "7 errors in empty disjunction:\nconflicting values [1] and bool (mismatched types list and bool):\n generated.cue:2:8\n instance.json:1:1\nconflicting values [1] and null (mismatched types list and null):\n generated.cue:2:1\n instance.json:1:1\nconflicting values [1] and number (mismatched types list and number):\n generated.cue:2:15\n instance.json:1:1\nconflicting values [1] and string (mismatched types list and string):\n generated.cue:2:24\n instance.json:1:1\nconflicting values [1] and {...} (mismatched types list and struct):\n generated.cue:2:49\n instance.json:1:1\nincompatible list lengths (1 and 3):\n generated.cue:2:33\nexplicit error (_|_ literal) in source:\n generated.cue:2:37\n" 175 } 176 }, 177 { 178 "description": "array with two items is invalid", 179 "data": [ 180 1, 181 "foo" 182 ], 183 "valid": false 184 }, 185 { 186 "description": "empty array is valid", 187 "data": [], 188 "valid": true, 189 "skip": { 190 "v2": "5 errors in empty disjunction:\nconflicting values [] and {...} (mismatched types list and struct):\n generated.cue:2:1\n generated.cue:2:49\n instance.json:1:1\nconflicting values bool and [] (mismatched types bool and list):\n generated.cue:2:8\n instance.json:1:1\nconflicting values null and [] (mismatched types null and list):\n generated.cue:2:1\n instance.json:1:1\nconflicting values number and [] (mismatched types number and list):\n generated.cue:2:15\n instance.json:1:1\nconflicting values string and [] (mismatched types string and list):\n generated.cue:2:24\n instance.json:1:1\n", 191 "v3": "6 errors in empty disjunction:\nconflicting values [] and bool (mismatched types list and bool):\n generated.cue:2:8\n instance.json:1:1\nconflicting values [] and null (mismatched types list and null):\n generated.cue:2:1\n instance.json:1:1\nconflicting values [] and number (mismatched types list and number):\n generated.cue:2:15\n instance.json:1:1\nconflicting values [] and string (mismatched types list and string):\n generated.cue:2:24\n instance.json:1:1\nconflicting values [] and {...} (mismatched types list and struct):\n generated.cue:2:49\n instance.json:1:1\nincompatible list lengths (0 and 3):\n generated.cue:2:33\n" 192 } 193 } 194 ] 195 }, 196 { 197 "description": "items and subitems", 198 "schema": { 199 "definitions": { 200 "item": { 201 "type": "array", 202 "additionalItems": false, 203 "items": [ 204 { 205 "$ref": "#/definitions/sub-item" 206 }, 207 { 208 "$ref": "#/definitions/sub-item" 209 } 210 ] 211 }, 212 "sub-item": { 213 "type": "object", 214 "required": [ 215 "foo" 216 ] 217 } 218 }, 219 "type": "array", 220 "additionalItems": false, 221 "items": [ 222 { 223 "$ref": "#/definitions/item" 224 }, 225 { 226 "$ref": "#/definitions/item" 227 }, 228 { 229 "$ref": "#/definitions/item" 230 } 231 ] 232 }, 233 "tests": [ 234 { 235 "description": "valid items", 236 "data": [ 237 [ 238 { 239 "foo": null 240 }, 241 { 242 "foo": null 243 } 244 ], 245 [ 246 { 247 "foo": null 248 }, 249 { 250 "foo": null 251 } 252 ], 253 [ 254 { 255 "foo": null 256 }, 257 { 258 "foo": null 259 } 260 ] 261 ], 262 "valid": true 263 }, 264 { 265 "description": "too many items", 266 "data": [ 267 [ 268 { 269 "foo": null 270 }, 271 { 272 "foo": null 273 } 274 ], 275 [ 276 { 277 "foo": null 278 }, 279 { 280 "foo": null 281 } 282 ], 283 [ 284 { 285 "foo": null 286 }, 287 { 288 "foo": null 289 } 290 ], 291 [ 292 { 293 "foo": null 294 }, 295 { 296 "foo": null 297 } 298 ] 299 ], 300 "valid": false 301 }, 302 { 303 "description": "too many sub-items", 304 "data": [ 305 [ 306 { 307 "foo": null 308 }, 309 { 310 "foo": null 311 }, 312 { 313 "foo": null 314 } 315 ], 316 [ 317 { 318 "foo": null 319 }, 320 { 321 "foo": null 322 } 323 ], 324 [ 325 { 326 "foo": null 327 }, 328 { 329 "foo": null 330 } 331 ] 332 ], 333 "valid": false 334 }, 335 { 336 "description": "wrong item", 337 "data": [ 338 { 339 "foo": null 340 }, 341 [ 342 { 343 "foo": null 344 }, 345 { 346 "foo": null 347 } 348 ], 349 [ 350 { 351 "foo": null 352 }, 353 { 354 "foo": null 355 } 356 ] 357 ], 358 "valid": false 359 }, 360 { 361 "description": "wrong sub-item", 362 "data": [ 363 [ 364 {}, 365 { 366 "foo": null 367 } 368 ], 369 [ 370 { 371 "foo": null 372 }, 373 { 374 "foo": null 375 } 376 ], 377 [ 378 { 379 "foo": null 380 }, 381 { 382 "foo": null 383 } 384 ] 385 ], 386 "valid": false 387 }, 388 { 389 "description": "fewer items is valid", 390 "data": [ 391 [ 392 { 393 "foo": null 394 } 395 ], 396 [ 397 { 398 "foo": null 399 } 400 ] 401 ], 402 "valid": true, 403 "skip": { 404 "v2": "incompatible list lengths (2 and 3)\n0: incompatible list lengths (1 and 2)\n1: incompatible list lengths (1 and 2)\n", 405 "v3": "incompatible list lengths (2 and 3):\n generated.cue:2:1\n0: incompatible list lengths (1 and 2):\n generated.cue:9:8\n" 406 } 407 } 408 ] 409 }, 410 { 411 "description": "nested items", 412 "schema": { 413 "type": "array", 414 "items": { 415 "type": "array", 416 "items": { 417 "type": "array", 418 "items": { 419 "type": "array", 420 "items": { 421 "type": "number" 422 } 423 } 424 } 425 } 426 }, 427 "tests": [ 428 { 429 "description": "valid nested array", 430 "data": [ 431 [ 432 [ 433 [ 434 1 435 ] 436 ], 437 [ 438 [ 439 2 440 ], 441 [ 442 3 443 ] 444 ] 445 ], 446 [ 447 [ 448 [ 449 4 450 ], 451 [ 452 5 453 ], 454 [ 455 6 456 ] 457 ] 458 ] 459 ], 460 "valid": true 461 }, 462 { 463 "description": "nested array with invalid type", 464 "data": [ 465 [ 466 [ 467 [ 468 "1" 469 ] 470 ], 471 [ 472 [ 473 2 474 ], 475 [ 476 3 477 ] 478 ] 479 ], 480 [ 481 [ 482 [ 483 4 484 ], 485 [ 486 5 487 ], 488 [ 489 6 490 ] 491 ] 492 ] 493 ], 494 "valid": false 495 }, 496 { 497 "description": "not deep enough", 498 "data": [ 499 [ 500 [ 501 1 502 ], 503 [ 504 2 505 ], 506 [ 507 3 508 ] 509 ], 510 [ 511 [ 512 4 513 ], 514 [ 515 5 516 ], 517 [ 518 6 519 ] 520 ] 521 ], 522 "valid": false 523 } 524 ] 525 }, 526 { 527 "description": "single-form items with null instance elements", 528 "schema": { 529 "items": { 530 "type": "null" 531 } 532 }, 533 "tests": [ 534 { 535 "description": "allows null elements", 536 "data": [ 537 null 538 ], 539 "valid": true 540 } 541 ] 542 }, 543 { 544 "description": "array-form items with null instance elements", 545 "schema": { 546 "items": [ 547 { 548 "type": "null" 549 } 550 ] 551 }, 552 "tests": [ 553 { 554 "description": "allows null elements", 555 "data": [ 556 null 557 ], 558 "valid": true 559 } 560 ] 561 } 562 ]