cuelang.org/go@v0.13.0/encoding/jsonschema/testdata/external/tests/draft2019-09/items.json (about)

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