github.com/kaptinlin/jsonschema@v0.4.6/testdata/JSON-Schema-Test-Suite/tests/draft-next/unevaluatedItems.json (about)

     1  [
     2      {
     3          "description": "unevaluatedItems true",
     4          "schema": {
     5              "$schema": "https://json-schema.org/draft/next/schema",
     6              "unevaluatedItems": true
     7          },
     8          "tests": [
     9              {
    10                  "description": "with no unevaluated items",
    11                  "data": [],
    12                  "valid": true
    13              },
    14              {
    15                  "description": "with unevaluated items",
    16                  "data": ["foo"],
    17                  "valid": true
    18              }
    19          ]
    20      },
    21      {
    22          "description": "unevaluatedItems false",
    23          "schema": {
    24              "$schema": "https://json-schema.org/draft/next/schema",
    25              "unevaluatedItems": false
    26          },
    27          "tests": [
    28              {
    29                  "description": "with no unevaluated items",
    30                  "data": [],
    31                  "valid": true
    32              },
    33              {
    34                  "description": "with unevaluated items",
    35                  "data": ["foo"],
    36                  "valid": false
    37              }
    38          ]
    39      },
    40      {
    41          "description": "unevaluatedItems as schema",
    42          "schema": {
    43              "$schema": "https://json-schema.org/draft/next/schema",
    44              "unevaluatedItems": { "type": "string" }
    45          },
    46          "tests": [
    47              {
    48                  "description": "with no unevaluated items",
    49                  "data": [],
    50                  "valid": true
    51              },
    52              {
    53                  "description": "with valid unevaluated items",
    54                  "data": ["foo"],
    55                  "valid": true
    56              },
    57              {
    58                  "description": "with invalid unevaluated items",
    59                  "data": [42],
    60                  "valid": false
    61              }
    62          ]
    63      },
    64      {
    65          "description": "unevaluatedItems with uniform items",
    66          "schema": {
    67              "$schema": "https://json-schema.org/draft/next/schema",
    68              "items": { "type": "string" },
    69              "unevaluatedItems": false
    70          },
    71          "tests": [
    72              {
    73                  "description": "unevaluatedItems doesn't apply",
    74                  "data": ["foo", "bar"],
    75                  "valid": true
    76              }
    77          ]
    78      },
    79      {
    80          "description": "unevaluatedItems with tuple",
    81          "schema": {
    82              "$schema": "https://json-schema.org/draft/next/schema",
    83              "prefixItems": [
    84                  { "type": "string" }
    85              ],
    86              "unevaluatedItems": false
    87          },
    88          "tests": [
    89              {
    90                  "description": "with no unevaluated items",
    91                  "data": ["foo"],
    92                  "valid": true
    93              },
    94              {
    95                  "description": "with unevaluated items",
    96                  "data": ["foo", "bar"],
    97                  "valid": false
    98              }
    99          ]
   100      },
   101      {
   102          "description": "unevaluatedItems with items and prefixItems",
   103          "schema": {
   104              "$schema": "https://json-schema.org/draft/next/schema",
   105              "prefixItems": [
   106                  { "type": "string" }
   107              ],
   108              "items": true,
   109              "unevaluatedItems": false
   110          },
   111          "tests": [
   112              {
   113                  "description": "unevaluatedItems doesn't apply",
   114                  "data": ["foo", 42],
   115                  "valid": true
   116              }
   117          ]
   118      },
   119      {
   120          "description": "unevaluatedItems with items",
   121          "schema": {
   122              "$schema": "https://json-schema.org/draft/next/schema",
   123              "items": {"type": "number"},
   124              "unevaluatedItems": {"type": "string"}
   125          },
   126          "tests": [
   127              {
   128                  "description": "valid under items",
   129                  "comment": "no elements are considered by unevaluatedItems",
   130                  "data": [5, 6, 7, 8],
   131                  "valid": true
   132              },
   133              {
   134                  "description": "invalid under items",
   135                  "data": ["foo", "bar", "baz"],
   136                  "valid": false
   137              }
   138          ]
   139      },
   140      {
   141          "description": "unevaluatedItems with nested tuple",
   142          "schema": {
   143              "$schema": "https://json-schema.org/draft/next/schema",
   144              "prefixItems": [
   145                  { "type": "string" }
   146              ],
   147              "allOf": [
   148                  {
   149                      "prefixItems": [
   150                          true,
   151                          { "type": "number" }
   152                      ]
   153                  }
   154              ],
   155              "unevaluatedItems": false
   156          },
   157          "tests": [
   158              {
   159                  "description": "with no unevaluated items",
   160                  "data": ["foo", 42],
   161                  "valid": true
   162              },
   163              {
   164                  "description": "with unevaluated items",
   165                  "data": ["foo", 42, true],
   166                  "valid": false
   167              }
   168          ]
   169      },
   170      {
   171          "description": "unevaluatedItems with nested items",
   172          "schema": {
   173              "$schema": "https://json-schema.org/draft/next/schema",
   174              "unevaluatedItems": {"type": "boolean"},
   175              "anyOf": [
   176                  { "items": {"type": "string"} },
   177                  true
   178              ]
   179          },
   180          "tests": [
   181              {
   182                  "description": "with only (valid) additional items",
   183                  "data": [true, false],
   184                  "valid": true
   185              },
   186              {
   187                  "description": "with no additional items",
   188                  "data": ["yes", "no"],
   189                  "valid": true
   190              },
   191              {
   192                  "description": "with invalid additional item",
   193                  "data": ["yes", false],
   194                  "valid": false
   195              }
   196          ]
   197      },
   198      {
   199          "description": "unevaluatedItems with nested prefixItems and items",
   200          "schema": {
   201              "$schema": "https://json-schema.org/draft/next/schema",
   202              "allOf": [
   203                  {
   204                      "prefixItems": [
   205                          { "type": "string" }
   206                      ],
   207                      "items": true
   208                  }
   209              ],
   210              "unevaluatedItems": false
   211          },
   212          "tests": [
   213              {
   214                  "description": "with no additional items",
   215                  "data": ["foo"],
   216                  "valid": true
   217              },
   218              {
   219                  "description": "with additional items",
   220                  "data": ["foo", 42, true],
   221                  "valid": true
   222              }
   223          ]
   224      },
   225      {
   226          "description": "unevaluatedItems with nested unevaluatedItems",
   227          "schema": {
   228              "$schema": "https://json-schema.org/draft/next/schema",
   229              "allOf": [
   230                  {
   231                      "prefixItems": [
   232                          { "type": "string" }
   233                      ]
   234                  },
   235                  { "unevaluatedItems": true }
   236              ],
   237              "unevaluatedItems": false
   238          },
   239          "tests": [
   240              {
   241                  "description": "with no additional items",
   242                  "data": ["foo"],
   243                  "valid": true
   244              },
   245              {
   246                  "description": "with additional items",
   247                  "data": ["foo", 42, true],
   248                  "valid": true
   249              }
   250          ]
   251      },
   252      {
   253          "description": "unevaluatedItems with anyOf",
   254          "schema": {
   255              "$schema": "https://json-schema.org/draft/next/schema",
   256              "prefixItems": [
   257                  { "const": "foo" }
   258              ],
   259              "anyOf": [
   260                  {
   261                      "prefixItems": [
   262                          true,
   263                          { "const": "bar" }
   264                      ]
   265                  },
   266                  {
   267                      "prefixItems": [
   268                          true,
   269                          true,
   270                          { "const": "baz" }
   271                      ]
   272                  }
   273              ],
   274              "unevaluatedItems": false
   275          },
   276          "tests": [
   277              {
   278                  "description": "when one schema matches and has no unevaluated items",
   279                  "data": ["foo", "bar"],
   280                  "valid": true
   281              },
   282              {
   283                  "description": "when one schema matches and has unevaluated items",
   284                  "data": ["foo", "bar", 42],
   285                  "valid": false
   286              },
   287              {
   288                  "description": "when two schemas match and has no unevaluated items",
   289                  "data": ["foo", "bar", "baz"],
   290                  "valid": true
   291              },
   292              {
   293                  "description": "when two schemas match and has unevaluated items",
   294                  "data": ["foo", "bar", "baz", 42],
   295                  "valid": false
   296              }
   297          ]
   298      },
   299      {
   300          "description": "unevaluatedItems with oneOf",
   301          "schema": {
   302              "$schema": "https://json-schema.org/draft/next/schema",
   303              "prefixItems": [
   304                  { "const": "foo" }
   305              ],
   306              "oneOf": [
   307                  {
   308                      "prefixItems": [
   309                          true,
   310                          { "const": "bar" }
   311                      ]
   312                  },
   313                  {
   314                      "prefixItems": [
   315                          true,
   316                          { "const": "baz" }
   317                      ]
   318                  }
   319              ],
   320              "unevaluatedItems": false
   321          },
   322          "tests": [
   323              {
   324                  "description": "with no unevaluated items",
   325                  "data": ["foo", "bar"],
   326                  "valid": true
   327              },
   328              {
   329                  "description": "with unevaluated items",
   330                  "data": ["foo", "bar", 42],
   331                  "valid": false
   332              }
   333          ]
   334      },
   335      {
   336          "description": "unevaluatedItems with not",
   337          "schema": {
   338              "$schema": "https://json-schema.org/draft/next/schema",
   339              "prefixItems": [
   340                  { "const": "foo" }
   341              ],
   342              "not": {
   343                  "not": {
   344                      "prefixItems": [
   345                          true,
   346                          { "const": "bar" }
   347                      ]
   348                  }
   349              },
   350              "unevaluatedItems": false
   351          },
   352          "tests": [
   353              {
   354                  "description": "with unevaluated items",
   355                  "data": ["foo", "bar"],
   356                  "valid": false
   357              }
   358          ]
   359      },
   360      {
   361          "description": "unevaluatedItems with if/then/else",
   362          "schema": {
   363              "$schema": "https://json-schema.org/draft/next/schema",
   364              "prefixItems": [
   365                  { "const": "foo" }
   366              ],
   367              "if": {
   368                  "prefixItems": [
   369                      true,
   370                      { "const": "bar" }
   371                  ]
   372              },
   373              "then": {
   374                  "prefixItems": [
   375                      true,
   376                      true,
   377                      { "const": "then" }
   378                  ]
   379              },
   380              "else": {
   381                  "prefixItems": [
   382                      true,
   383                      true,
   384                      true,
   385                      { "const": "else" }
   386                  ]
   387              },
   388              "unevaluatedItems": false
   389          },
   390          "tests": [
   391              {
   392                  "description": "when if matches and it has no unevaluated items",
   393                  "data": ["foo", "bar", "then"],
   394                  "valid": true
   395              },
   396              {
   397                  "description": "when if matches and it has unevaluated items",
   398                  "data": ["foo", "bar", "then", "else"],
   399                  "valid": false
   400              },
   401              {
   402                  "description": "when if doesn't match and it has no unevaluated items",
   403                  "data": ["foo", 42, 42, "else"],
   404                  "valid": true
   405              },
   406              {
   407                  "description": "when if doesn't match and it has unevaluated items",
   408                  "data": ["foo", 42, 42, "else", 42],
   409                  "valid": false
   410              }
   411          ]
   412      },
   413      {
   414          "description": "unevaluatedItems with boolean schemas",
   415          "schema": {
   416              "$schema": "https://json-schema.org/draft/next/schema",
   417              "allOf": [true],
   418              "unevaluatedItems": false
   419          },
   420          "tests": [
   421              {
   422                  "description": "with no unevaluated items",
   423                  "data": [],
   424                  "valid": true
   425              },
   426              {
   427                  "description": "with unevaluated items",
   428                  "data": ["foo"],
   429                  "valid": false
   430              }
   431          ]
   432      },
   433      {
   434          "description": "unevaluatedItems with $ref",
   435          "schema": {
   436              "$schema": "https://json-schema.org/draft/next/schema",
   437              "$ref": "#/$defs/bar",
   438              "prefixItems": [
   439                  { "type": "string" }
   440              ],
   441              "unevaluatedItems": false,
   442              "$defs": {
   443                "bar": {
   444                    "prefixItems": [
   445                        true,
   446                        { "type": "string" }
   447                    ]
   448                }
   449              }
   450          },
   451          "tests": [
   452              {
   453                  "description": "with no unevaluated items",
   454                  "data": ["foo", "bar"],
   455                  "valid": true
   456              },
   457              {
   458                  "description": "with unevaluated items",
   459                  "data": ["foo", "bar", "baz"],
   460                  "valid": false
   461              }
   462          ]
   463      },
   464      {
   465          "description": "unevaluatedItems before $ref",
   466          "schema": {
   467              "$schema": "https://json-schema.org/draft/next/schema",
   468              "unevaluatedItems": false,
   469              "prefixItems": [
   470                  { "type": "string" }
   471              ],
   472              "$ref": "#/$defs/bar",
   473              "$defs": {
   474                "bar": {
   475                    "prefixItems": [
   476                        true,
   477                        { "type": "string" }
   478                    ]
   479                }
   480              }
   481          },
   482          "tests": [
   483              {
   484                  "description": "with no unevaluated items",
   485                  "data": ["foo", "bar"],
   486                  "valid": true
   487              },
   488              {
   489                  "description": "with unevaluated items",
   490                  "data": ["foo", "bar", "baz"],
   491                  "valid": false
   492              }
   493          ]
   494      },
   495      {
   496          "description": "unevaluatedItems with $dynamicRef",
   497          "schema": {
   498              "$schema": "https://json-schema.org/draft/next/schema",
   499              "$id": "https://example.com/unevaluated-items-with-dynamic-ref/derived",
   500  
   501              "$ref": "./baseSchema",
   502  
   503              "$defs": {
   504                  "derived": {
   505                      "$dynamicAnchor": "addons",
   506                      "prefixItems": [
   507                          true,
   508                          { "type": "string" }
   509                      ]
   510                  },
   511                  "baseSchema": {
   512                      "$id": "./baseSchema",
   513  
   514                      "$comment": "unevaluatedItems comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
   515                      "unevaluatedItems": false,
   516                      "type": "array",
   517                      "prefixItems": [
   518                          { "type": "string" }
   519                      ],
   520                      "$dynamicRef": "#addons"
   521                  }
   522              }
   523          },
   524          "tests": [
   525              {
   526                  "description": "with no unevaluated items",
   527                  "data": ["foo", "bar"],
   528                  "valid": true
   529              },
   530              {
   531                  "description": "with unevaluated items",
   532                  "data": ["foo", "bar", "baz"],
   533                  "valid": false
   534              }
   535          ]
   536      },
   537      {
   538          "description": "unevaluatedItems can't see inside cousins",
   539          "schema": {
   540              "$schema": "https://json-schema.org/draft/next/schema",
   541              "allOf": [
   542                  {
   543                      "prefixItems": [ true ]
   544                  },
   545                  { "unevaluatedItems": false }
   546              ]
   547          },
   548          "tests": [
   549              {
   550                  "description": "always fails",
   551                  "data": [ 1 ],
   552                  "valid": false
   553              }
   554          ]
   555      },
   556      {
   557          "description": "item is evaluated in an uncle schema to unevaluatedItems",
   558          "schema": {
   559              "$schema": "https://json-schema.org/draft/next/schema",
   560              "properties": {
   561                  "foo": {
   562                      "prefixItems": [
   563                          { "type": "string" }
   564                      ],
   565                      "unevaluatedItems": false
   566                    }
   567              },
   568              "anyOf": [
   569                  {
   570                      "properties": {
   571                          "foo": {
   572                              "prefixItems": [
   573                                  true,
   574                                  { "type": "string" }
   575                              ]
   576                          }
   577                      }
   578                  }
   579              ]
   580          },
   581          "tests": [
   582              {
   583                  "description": "no extra items",
   584                  "data": {
   585                      "foo": [
   586                          "test"
   587                      ]
   588                  },
   589                  "valid": true
   590              },
   591              {
   592                  "description": "uncle keyword evaluation is not significant",
   593                  "data": {
   594                      "foo": [
   595                          "test",
   596                          "test"
   597                      ]
   598                  },
   599                  "valid": false
   600              }
   601          ]
   602      },
   603      {
   604          "description": "unevaluatedItems depends on adjacent contains",
   605          "schema": {
   606              "$schema": "https://json-schema.org/draft/next/schema",
   607              "prefixItems": [true],
   608              "contains": {"type": "string"},
   609              "unevaluatedItems": false
   610          },
   611          "tests": [
   612              {
   613                  "description": "second item is evaluated by contains",
   614                  "data": [ 1, "foo" ],
   615                  "valid": true
   616              },
   617              {
   618                  "description": "contains fails, second item is not evaluated",
   619                  "data": [ 1, 2 ],
   620                  "valid": false
   621              },
   622              {
   623                  "description": "contains passes, second item is not evaluated",
   624                  "data": [ 1, 2, "foo" ],
   625                  "valid": false
   626              }
   627          ]
   628      },
   629      {
   630          "description": "unevaluatedItems depends on multiple nested contains",
   631          "schema": {
   632              "$schema": "https://json-schema.org/draft/next/schema",
   633              "allOf": [
   634                  { "contains": { "multipleOf": 2 } },
   635                  { "contains": { "multipleOf": 3 } }
   636              ],
   637              "unevaluatedItems": { "multipleOf": 5 }
   638          },
   639          "tests": [
   640              {
   641                  "description": "5 not evaluated, passes unevaluatedItems",
   642                  "data": [ 2, 3, 4, 5, 6 ],
   643                  "valid": true
   644              },
   645              {
   646                  "description": "7 not evaluated, fails unevaluatedItems",
   647                  "data": [ 2, 3, 4, 7, 8 ],
   648                  "valid": false
   649              }
   650          ]
   651      },
   652      {
   653          "description": "unevaluatedItems and contains interact to control item dependency relationship",
   654          "schema": {
   655              "$schema": "https://json-schema.org/draft/next/schema",
   656              "if": {
   657                  "contains": {"const": "a"}
   658              },
   659              "then": {
   660                  "if": {
   661                      "contains": {"const": "b"}
   662                  },
   663                  "then": {
   664                      "if": {
   665                          "contains": {"const": "c"}
   666                      }
   667                  }
   668              },
   669              "unevaluatedItems": false
   670          },
   671          "tests": [
   672              {
   673                  "description": "empty array is valid",
   674                  "data": [],
   675                  "valid": true
   676              },
   677              {
   678                  "description": "only a's are valid",
   679                  "data": [ "a", "a" ],
   680                  "valid": true
   681              },
   682              {
   683                  "description": "a's and b's are valid",
   684                  "data": [ "a", "b", "a", "b", "a" ],
   685                  "valid": true
   686              },
   687              {
   688                  "description": "a's, b's and c's are valid",
   689                  "data": [ "c", "a", "c", "c", "b", "a" ],
   690                  "valid": true
   691              },
   692              {
   693                  "description": "only b's are invalid",
   694                  "data": [ "b", "b" ],
   695                  "valid": false
   696              },
   697              {
   698                  "description": "only c's are invalid",
   699                  "data": [ "c", "c" ],
   700                  "valid": false
   701              },
   702              {
   703                  "description": "only b's and c's are invalid",
   704                  "data": [ "c", "b", "c", "b", "c" ],
   705                  "valid": false
   706              },
   707              {
   708                  "description": "only a's and c's are invalid",
   709                  "data": [ "c", "a", "c", "a", "c" ],
   710                  "valid": false
   711              }
   712          ]
   713      },
   714      {
   715          "description": "non-array instances are valid",
   716          "schema": {
   717              "$schema": "https://json-schema.org/draft/next/schema",
   718              "unevaluatedItems": false
   719          },
   720          "tests": [
   721              {
   722                  "description": "ignores booleans",
   723                  "data": true,
   724                  "valid": true
   725              },
   726              {
   727                  "description": "ignores integers",
   728                  "data": 123,
   729                  "valid": true
   730              },
   731              {
   732                  "description": "ignores floats",
   733                  "data": 1.0,
   734                  "valid": true
   735              },
   736              {
   737                  "description": "ignores objects",
   738                  "data": {},
   739                  "valid": true
   740              },
   741              {
   742                  "description": "ignores strings",
   743                  "data": "foo",
   744                  "valid": true
   745              },
   746              {
   747                  "description": "ignores null",
   748                  "data": null,
   749                  "valid": true
   750              }
   751          ]
   752      },
   753      {
   754          "description": "unevaluatedItems with null instance elements",
   755          "schema": {
   756              "$schema": "https://json-schema.org/draft/next/schema",
   757              "unevaluatedItems": {
   758                  "type": "null"
   759              }
   760          },
   761          "tests": [
   762              {
   763                  "description": "allows null elements",
   764                  "data": [ null ],
   765                  "valid": true
   766              }
   767          ]
   768      },
   769      {
   770          "description": "unevaluatedItems can see annotations from if without then and else",
   771          "schema": {
   772              "$schema": "https://json-schema.org/draft/next/schema",
   773              "if": {
   774                  "prefixItems": [{"const": "a"}]
   775              },
   776              "unevaluatedItems": false
   777          },
   778          "tests": [
   779              {
   780                  "description": "valid in case if is evaluated",
   781                  "data": [ "a" ],
   782                  "valid": true
   783              },
   784              {
   785                  "description": "invalid in case if is evaluated",
   786                  "data": [ "b" ],
   787                  "valid": false
   788              }
   789  
   790          ]
   791      }
   792  ]