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

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