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

     1  [
     2  	{
     3  		"description": "$recursiveRef without $recursiveAnchor works like $ref",
     4  		"schema": {
     5  			"$schema": "https://json-schema.org/draft/2019-09/schema",
     6  			"properties": {
     7  				"foo": {
     8  					"$recursiveRef": "#"
     9  				}
    10  			},
    11  			"additionalProperties": false
    12  		},
    13  		"skip": {
    14  			"v2": "extract error: keyword \"$recursiveRef\" not yet implemented",
    15  			"v3": "extract error: keyword \"$recursiveRef\" not yet implemented"
    16  		},
    17  		"tests": [
    18  			{
    19  				"description": "match",
    20  				"data": {
    21  					"foo": false
    22  				},
    23  				"valid": true,
    24  				"skip": {
    25  					"v2": "could not compile schema",
    26  					"v3": "could not compile schema"
    27  				}
    28  			},
    29  			{
    30  				"description": "recursive match",
    31  				"data": {
    32  					"foo": {
    33  						"foo": false
    34  					}
    35  				},
    36  				"valid": true,
    37  				"skip": {
    38  					"v2": "could not compile schema",
    39  					"v3": "could not compile schema"
    40  				}
    41  			},
    42  			{
    43  				"description": "mismatch",
    44  				"data": {
    45  					"bar": false
    46  				},
    47  				"valid": false,
    48  				"skip": {
    49  					"v2": "could not compile schema",
    50  					"v3": "could not compile schema"
    51  				}
    52  			},
    53  			{
    54  				"description": "recursive mismatch",
    55  				"data": {
    56  					"foo": {
    57  						"bar": false
    58  					}
    59  				},
    60  				"valid": false,
    61  				"skip": {
    62  					"v2": "could not compile schema",
    63  					"v3": "could not compile schema"
    64  				}
    65  			}
    66  		]
    67  	},
    68  	{
    69  		"description": "$recursiveRef without using nesting",
    70  		"schema": {
    71  			"$schema": "https://json-schema.org/draft/2019-09/schema",
    72  			"$id": "http://localhost:4242/draft2019-09/recursiveRef2/schema.json",
    73  			"$defs": {
    74  				"myobject": {
    75  					"$id": "myobject.json",
    76  					"$recursiveAnchor": true,
    77  					"anyOf": [
    78  						{
    79  							"type": "string"
    80  						},
    81  						{
    82  							"type": "object",
    83  							"additionalProperties": {
    84  								"$recursiveRef": "#"
    85  							}
    86  						}
    87  					]
    88  				}
    89  			},
    90  			"anyOf": [
    91  				{
    92  					"type": "integer"
    93  				},
    94  				{
    95  					"$ref": "#/$defs/myobject"
    96  				}
    97  			]
    98  		},
    99  		"skip": {
   100  			"v2": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 3 more errors)",
   101  			"v3": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 3 more errors)"
   102  		},
   103  		"tests": [
   104  			{
   105  				"description": "integer matches at the outer level",
   106  				"data": 1,
   107  				"valid": true,
   108  				"skip": {
   109  					"v2": "could not compile schema",
   110  					"v3": "could not compile schema"
   111  				}
   112  			},
   113  			{
   114  				"description": "single level match",
   115  				"data": {
   116  					"foo": "hi"
   117  				},
   118  				"valid": true,
   119  				"skip": {
   120  					"v2": "could not compile schema",
   121  					"v3": "could not compile schema"
   122  				}
   123  			},
   124  			{
   125  				"description": "integer does not match as a property value",
   126  				"data": {
   127  					"foo": 1
   128  				},
   129  				"valid": false,
   130  				"skip": {
   131  					"v2": "could not compile schema",
   132  					"v3": "could not compile schema"
   133  				}
   134  			},
   135  			{
   136  				"description": "two levels, properties match with inner definition",
   137  				"data": {
   138  					"foo": {
   139  						"bar": "hi"
   140  					}
   141  				},
   142  				"valid": true,
   143  				"skip": {
   144  					"v2": "could not compile schema",
   145  					"v3": "could not compile schema"
   146  				}
   147  			},
   148  			{
   149  				"description": "two levels, no match",
   150  				"data": {
   151  					"foo": {
   152  						"bar": 1
   153  					}
   154  				},
   155  				"valid": false,
   156  				"skip": {
   157  					"v2": "could not compile schema",
   158  					"v3": "could not compile schema"
   159  				}
   160  			}
   161  		]
   162  	},
   163  	{
   164  		"description": "$recursiveRef with nesting",
   165  		"schema": {
   166  			"$schema": "https://json-schema.org/draft/2019-09/schema",
   167  			"$id": "http://localhost:4242/draft2019-09/recursiveRef3/schema.json",
   168  			"$recursiveAnchor": true,
   169  			"$defs": {
   170  				"myobject": {
   171  					"$id": "myobject.json",
   172  					"$recursiveAnchor": true,
   173  					"anyOf": [
   174  						{
   175  							"type": "string"
   176  						},
   177  						{
   178  							"type": "object",
   179  							"additionalProperties": {
   180  								"$recursiveRef": "#"
   181  							}
   182  						}
   183  					]
   184  				}
   185  			},
   186  			"anyOf": [
   187  				{
   188  					"type": "integer"
   189  				},
   190  				{
   191  					"$ref": "#/$defs/myobject"
   192  				}
   193  			]
   194  		},
   195  		"skip": {
   196  			"v2": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 5 more errors)",
   197  			"v3": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 5 more errors)"
   198  		},
   199  		"tests": [
   200  			{
   201  				"description": "integer matches at the outer level",
   202  				"data": 1,
   203  				"valid": true,
   204  				"skip": {
   205  					"v2": "could not compile schema",
   206  					"v3": "could not compile schema"
   207  				}
   208  			},
   209  			{
   210  				"description": "single level match",
   211  				"data": {
   212  					"foo": "hi"
   213  				},
   214  				"valid": true,
   215  				"skip": {
   216  					"v2": "could not compile schema",
   217  					"v3": "could not compile schema"
   218  				}
   219  			},
   220  			{
   221  				"description": "integer now matches as a property value",
   222  				"data": {
   223  					"foo": 1
   224  				},
   225  				"valid": true,
   226  				"skip": {
   227  					"v2": "could not compile schema",
   228  					"v3": "could not compile schema"
   229  				}
   230  			},
   231  			{
   232  				"description": "two levels, properties match with inner definition",
   233  				"data": {
   234  					"foo": {
   235  						"bar": "hi"
   236  					}
   237  				},
   238  				"valid": true,
   239  				"skip": {
   240  					"v2": "could not compile schema",
   241  					"v3": "could not compile schema"
   242  				}
   243  			},
   244  			{
   245  				"description": "two levels, properties match with $recursiveRef",
   246  				"data": {
   247  					"foo": {
   248  						"bar": 1
   249  					}
   250  				},
   251  				"valid": true,
   252  				"skip": {
   253  					"v2": "could not compile schema",
   254  					"v3": "could not compile schema"
   255  				}
   256  			}
   257  		]
   258  	},
   259  	{
   260  		"description": "$recursiveRef with $recursiveAnchor: false works like $ref",
   261  		"schema": {
   262  			"$schema": "https://json-schema.org/draft/2019-09/schema",
   263  			"$id": "http://localhost:4242/draft2019-09/recursiveRef4/schema.json",
   264  			"$recursiveAnchor": false,
   265  			"$defs": {
   266  				"myobject": {
   267  					"$id": "myobject.json",
   268  					"$recursiveAnchor": false,
   269  					"anyOf": [
   270  						{
   271  							"type": "string"
   272  						},
   273  						{
   274  							"type": "object",
   275  							"additionalProperties": {
   276  								"$recursiveRef": "#"
   277  							}
   278  						}
   279  					]
   280  				}
   281  			},
   282  			"anyOf": [
   283  				{
   284  					"type": "integer"
   285  				},
   286  				{
   287  					"$ref": "#/$defs/myobject"
   288  				}
   289  			]
   290  		},
   291  		"skip": {
   292  			"v2": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 5 more errors)",
   293  			"v3": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 5 more errors)"
   294  		},
   295  		"tests": [
   296  			{
   297  				"description": "integer matches at the outer level",
   298  				"data": 1,
   299  				"valid": true,
   300  				"skip": {
   301  					"v2": "could not compile schema",
   302  					"v3": "could not compile schema"
   303  				}
   304  			},
   305  			{
   306  				"description": "single level match",
   307  				"data": {
   308  					"foo": "hi"
   309  				},
   310  				"valid": true,
   311  				"skip": {
   312  					"v2": "could not compile schema",
   313  					"v3": "could not compile schema"
   314  				}
   315  			},
   316  			{
   317  				"description": "integer does not match as a property value",
   318  				"data": {
   319  					"foo": 1
   320  				},
   321  				"valid": false,
   322  				"skip": {
   323  					"v2": "could not compile schema",
   324  					"v3": "could not compile schema"
   325  				}
   326  			},
   327  			{
   328  				"description": "two levels, properties match with inner definition",
   329  				"data": {
   330  					"foo": {
   331  						"bar": "hi"
   332  					}
   333  				},
   334  				"valid": true,
   335  				"skip": {
   336  					"v2": "could not compile schema",
   337  					"v3": "could not compile schema"
   338  				}
   339  			},
   340  			{
   341  				"description": "two levels, integer does not match as a property value",
   342  				"data": {
   343  					"foo": {
   344  						"bar": 1
   345  					}
   346  				},
   347  				"valid": false,
   348  				"skip": {
   349  					"v2": "could not compile schema",
   350  					"v3": "could not compile schema"
   351  				}
   352  			}
   353  		]
   354  	},
   355  	{
   356  		"description": "$recursiveRef with no $recursiveAnchor works like $ref",
   357  		"schema": {
   358  			"$schema": "https://json-schema.org/draft/2019-09/schema",
   359  			"$id": "http://localhost:4242/draft2019-09/recursiveRef5/schema.json",
   360  			"$defs": {
   361  				"myobject": {
   362  					"$id": "myobject.json",
   363  					"$recursiveAnchor": false,
   364  					"anyOf": [
   365  						{
   366  							"type": "string"
   367  						},
   368  						{
   369  							"type": "object",
   370  							"additionalProperties": {
   371  								"$recursiveRef": "#"
   372  							}
   373  						}
   374  					]
   375  				}
   376  			},
   377  			"anyOf": [
   378  				{
   379  					"type": "integer"
   380  				},
   381  				{
   382  					"$ref": "#/$defs/myobject"
   383  				}
   384  			]
   385  		},
   386  		"skip": {
   387  			"v2": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 3 more errors)",
   388  			"v3": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 3 more errors)"
   389  		},
   390  		"tests": [
   391  			{
   392  				"description": "integer matches at the outer level",
   393  				"data": 1,
   394  				"valid": true,
   395  				"skip": {
   396  					"v2": "could not compile schema",
   397  					"v3": "could not compile schema"
   398  				}
   399  			},
   400  			{
   401  				"description": "single level match",
   402  				"data": {
   403  					"foo": "hi"
   404  				},
   405  				"valid": true,
   406  				"skip": {
   407  					"v2": "could not compile schema",
   408  					"v3": "could not compile schema"
   409  				}
   410  			},
   411  			{
   412  				"description": "integer does not match as a property value",
   413  				"data": {
   414  					"foo": 1
   415  				},
   416  				"valid": false,
   417  				"skip": {
   418  					"v2": "could not compile schema",
   419  					"v3": "could not compile schema"
   420  				}
   421  			},
   422  			{
   423  				"description": "two levels, properties match with inner definition",
   424  				"data": {
   425  					"foo": {
   426  						"bar": "hi"
   427  					}
   428  				},
   429  				"valid": true,
   430  				"skip": {
   431  					"v2": "could not compile schema",
   432  					"v3": "could not compile schema"
   433  				}
   434  			},
   435  			{
   436  				"description": "two levels, integer does not match as a property value",
   437  				"data": {
   438  					"foo": {
   439  						"bar": 1
   440  					}
   441  				},
   442  				"valid": false,
   443  				"skip": {
   444  					"v2": "could not compile schema",
   445  					"v3": "could not compile schema"
   446  				}
   447  			}
   448  		]
   449  	},
   450  	{
   451  		"description": "$recursiveRef with no $recursiveAnchor in the initial target schema resource",
   452  		"schema": {
   453  			"$schema": "https://json-schema.org/draft/2019-09/schema",
   454  			"$id": "http://localhost:4242/draft2019-09/recursiveRef6/base.json",
   455  			"$recursiveAnchor": true,
   456  			"anyOf": [
   457  				{
   458  					"type": "boolean"
   459  				},
   460  				{
   461  					"type": "object",
   462  					"additionalProperties": {
   463  						"$id": "http://localhost:4242/draft2019-09/recursiveRef6/inner.json",
   464  						"$comment": "there is no $recursiveAnchor: true here, so we do NOT recurse to the base",
   465  						"anyOf": [
   466  							{
   467  								"type": "integer"
   468  							},
   469  							{
   470  								"type": "object",
   471  								"additionalProperties": {
   472  									"$recursiveRef": "#"
   473  								}
   474  							}
   475  						]
   476  					}
   477  				}
   478  			]
   479  		},
   480  		"skip": {
   481  			"v2": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 3 more errors)",
   482  			"v3": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 3 more errors)"
   483  		},
   484  		"tests": [
   485  			{
   486  				"description": "leaf node does not match; no recursion",
   487  				"data": {
   488  					"foo": true
   489  				},
   490  				"valid": false,
   491  				"skip": {
   492  					"v2": "could not compile schema",
   493  					"v3": "could not compile schema"
   494  				}
   495  			},
   496  			{
   497  				"description": "leaf node matches: recursion uses the inner schema",
   498  				"data": {
   499  					"foo": {
   500  						"bar": 1
   501  					}
   502  				},
   503  				"valid": true,
   504  				"skip": {
   505  					"v2": "could not compile schema",
   506  					"v3": "could not compile schema"
   507  				}
   508  			},
   509  			{
   510  				"description": "leaf node does not match: recursion uses the inner schema",
   511  				"data": {
   512  					"foo": {
   513  						"bar": true
   514  					}
   515  				},
   516  				"valid": false,
   517  				"skip": {
   518  					"v2": "could not compile schema",
   519  					"v3": "could not compile schema"
   520  				}
   521  			}
   522  		]
   523  	},
   524  	{
   525  		"description": "$recursiveRef with no $recursiveAnchor in the outer schema resource",
   526  		"schema": {
   527  			"$schema": "https://json-schema.org/draft/2019-09/schema",
   528  			"$id": "http://localhost:4242/draft2019-09/recursiveRef7/base.json",
   529  			"anyOf": [
   530  				{
   531  					"type": "boolean"
   532  				},
   533  				{
   534  					"type": "object",
   535  					"additionalProperties": {
   536  						"$id": "http://localhost:4242/draft2019-09/recursiveRef7/inner.json",
   537  						"$recursiveAnchor": true,
   538  						"anyOf": [
   539  							{
   540  								"type": "integer"
   541  							},
   542  							{
   543  								"type": "object",
   544  								"additionalProperties": {
   545  									"$recursiveRef": "#"
   546  								}
   547  							}
   548  						]
   549  					}
   550  				}
   551  			]
   552  		},
   553  		"skip": {
   554  			"v2": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 3 more errors)",
   555  			"v3": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 3 more errors)"
   556  		},
   557  		"tests": [
   558  			{
   559  				"description": "leaf node does not match; no recursion",
   560  				"data": {
   561  					"foo": true
   562  				},
   563  				"valid": false,
   564  				"skip": {
   565  					"v2": "could not compile schema",
   566  					"v3": "could not compile schema"
   567  				}
   568  			},
   569  			{
   570  				"description": "leaf node matches: recursion only uses inner schema",
   571  				"data": {
   572  					"foo": {
   573  						"bar": 1
   574  					}
   575  				},
   576  				"valid": true,
   577  				"skip": {
   578  					"v2": "could not compile schema",
   579  					"v3": "could not compile schema"
   580  				}
   581  			},
   582  			{
   583  				"description": "leaf node does not match: recursion only uses inner schema",
   584  				"data": {
   585  					"foo": {
   586  						"bar": true
   587  					}
   588  				},
   589  				"valid": false,
   590  				"skip": {
   591  					"v2": "could not compile schema",
   592  					"v3": "could not compile schema"
   593  				}
   594  			}
   595  		]
   596  	},
   597  	{
   598  		"description": "multiple dynamic paths to the $recursiveRef keyword",
   599  		"schema": {
   600  			"$schema": "https://json-schema.org/draft/2019-09/schema",
   601  			"$id": "https://example.com/recursiveRef8_main.json",
   602  			"$defs": {
   603  				"inner": {
   604  					"$id": "recursiveRef8_inner.json",
   605  					"$recursiveAnchor": true,
   606  					"title": "inner",
   607  					"additionalProperties": {
   608  						"$recursiveRef": "#"
   609  					}
   610  				}
   611  			},
   612  			"if": {
   613  				"propertyNames": {
   614  					"pattern": "^[a-m]"
   615  				}
   616  			},
   617  			"then": {
   618  				"title": "any type of node",
   619  				"$id": "recursiveRef8_anyLeafNode.json",
   620  				"$recursiveAnchor": true,
   621  				"$ref": "recursiveRef8_inner.json"
   622  			},
   623  			"else": {
   624  				"title": "integer node",
   625  				"$id": "recursiveRef8_integerNode.json",
   626  				"$recursiveAnchor": true,
   627  				"type": [
   628  					"object",
   629  					"integer"
   630  				],
   631  				"$ref": "recursiveRef8_inner.json"
   632  			}
   633  		},
   634  		"skip": {
   635  			"v2": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 7 more errors)",
   636  			"v3": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 7 more errors)"
   637  		},
   638  		"tests": [
   639  			{
   640  				"description": "recurse to anyLeafNode - floats are allowed",
   641  				"data": {
   642  					"alpha": 1.1
   643  				},
   644  				"valid": true,
   645  				"skip": {
   646  					"v2": "could not compile schema",
   647  					"v3": "could not compile schema"
   648  				}
   649  			},
   650  			{
   651  				"description": "recurse to integerNode - floats are not allowed",
   652  				"data": {
   653  					"november": 1.1
   654  				},
   655  				"valid": false,
   656  				"skip": {
   657  					"v2": "could not compile schema",
   658  					"v3": "could not compile schema"
   659  				}
   660  			}
   661  		]
   662  	},
   663  	{
   664  		"description": "dynamic $recursiveRef destination (not predictable at schema compile time)",
   665  		"schema": {
   666  			"$schema": "https://json-schema.org/draft/2019-09/schema",
   667  			"$id": "https://example.com/main.json",
   668  			"$defs": {
   669  				"inner": {
   670  					"$id": "inner.json",
   671  					"$recursiveAnchor": true,
   672  					"title": "inner",
   673  					"additionalProperties": {
   674  						"$recursiveRef": "#"
   675  					}
   676  				}
   677  			},
   678  			"if": {
   679  				"propertyNames": {
   680  					"pattern": "^[a-m]"
   681  				}
   682  			},
   683  			"then": {
   684  				"title": "any type of node",
   685  				"$id": "anyLeafNode.json",
   686  				"$recursiveAnchor": true,
   687  				"$ref": "main.json#/$defs/inner"
   688  			},
   689  			"else": {
   690  				"title": "integer node",
   691  				"$id": "integerNode.json",
   692  				"$recursiveAnchor": true,
   693  				"type": [
   694  					"object",
   695  					"integer"
   696  				],
   697  				"$ref": "main.json#/$defs/inner"
   698  			}
   699  		},
   700  		"skip": {
   701  			"v2": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 7 more errors)",
   702  			"v3": "extract error: keyword \"$recursiveAnchor\" not yet implemented (and 7 more errors)"
   703  		},
   704  		"tests": [
   705  			{
   706  				"description": "numeric node",
   707  				"data": {
   708  					"alpha": 1.1
   709  				},
   710  				"valid": true,
   711  				"skip": {
   712  					"v2": "could not compile schema",
   713  					"v3": "could not compile schema"
   714  				}
   715  			},
   716  			{
   717  				"description": "integer node",
   718  				"data": {
   719  					"november": 1.1
   720  				},
   721  				"valid": false,
   722  				"skip": {
   723  					"v2": "could not compile schema",
   724  					"v3": "could not compile schema"
   725  				}
   726  			}
   727  		]
   728  	}
   729  ]