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

     1  [
     2      {
     3          "description": "additionalItems as schema",
     4          "schema": {
     5              "items": [{}],
     6              "additionalItems": {"type": "integer"}
     7          },
     8          "tests": [
     9              {
    10                  "description": "additional items match schema",
    11                  "data": [ null, 2, 3, 4 ],
    12                  "valid": true
    13              },
    14              {
    15                  "description": "additional items do not match schema",
    16                  "data": [ null, 2, 3, "foo" ],
    17                  "valid": false
    18              }
    19          ]
    20      },
    21      {
    22          "description": "when items is schema, additionalItems does nothing",
    23          "schema": {
    24              "items": {
    25                  "type": "integer"
    26              },
    27              "additionalItems": {
    28                  "type": "string"
    29              }
    30          },
    31          "tests": [
    32              {
    33                  "description": "valid with a array of type integers",
    34                  "data": [1,2,3],
    35                  "valid": true
    36              },
    37              {
    38                  "description": "invalid with a array of mixed types",
    39                  "data": [1,"2","3"],
    40                  "valid": false
    41              }
    42          ]
    43      },
    44      {
    45          "description": "when items is schema, boolean additionalItems does nothing",
    46          "schema": {
    47              "items": {},
    48              "additionalItems": false
    49          },
    50          "tests": [
    51              {
    52                  "description": "all items match schema",
    53                  "data": [ 1, 2, 3, 4, 5 ],
    54                  "valid": true
    55              }
    56          ]
    57      },
    58      {
    59          "description": "array of items with no additionalItems permitted",
    60          "schema": {
    61              "items": [{}, {}, {}],
    62              "additionalItems": false
    63          },
    64          "tests": [
    65              {
    66                  "description": "empty array",
    67                  "data": [ ],
    68                  "valid": true
    69              },
    70              {
    71                  "description": "fewer number of items present (1)",
    72                  "data": [ 1 ],
    73                  "valid": true
    74              },
    75              {
    76                  "description": "fewer number of items present (2)",
    77                  "data": [ 1, 2 ],
    78                  "valid": true
    79              },
    80              {
    81                  "description": "equal number of items present",
    82                  "data": [ 1, 2, 3 ],
    83                  "valid": true
    84              },
    85              {
    86                  "description": "additional items are not permitted",
    87                  "data": [ 1, 2, 3, 4 ],
    88                  "valid": false
    89              }
    90          ]
    91      },
    92      {
    93          "description": "additionalItems as false without items",
    94          "schema": {"additionalItems": false},
    95          "tests": [
    96              {
    97                  "description":
    98                      "items defaults to empty schema so everything is valid",
    99                  "data": [ 1, 2, 3, 4, 5 ],
   100                  "valid": true
   101              },
   102              {
   103                  "description": "ignores non-arrays",
   104                  "data": {"foo" : "bar"},
   105                  "valid": true
   106              }
   107          ]
   108      },
   109      {
   110          "description": "additionalItems are allowed by default",
   111          "schema": {"items": [{"type": "integer"}]},
   112          "tests": [
   113              {
   114                  "description": "only the first item is validated",
   115                  "data": [1, "foo", false],
   116                  "valid": true
   117              }
   118          ]
   119      },
   120      {
   121          "description": "additionalItems does not look in applicators, valid case",
   122          "schema": {
   123              "allOf": [
   124                  { "items": [ { "type": "integer" } ] }
   125              ],
   126              "additionalItems": { "type": "boolean" }
   127          },
   128          "tests": [
   129              {
   130                  "description": "items defined in allOf are not examined",
   131                  "data": [ 1, null ],
   132                  "valid": true
   133              }
   134          ]
   135      },
   136      {
   137          "description": "additionalItems does not look in applicators, invalid case",
   138          "schema": {
   139              "allOf": [
   140                  { "items": [ { "type": "integer" }, { "type": "string" } ] }
   141              ],
   142              "items": [ {"type": "integer" } ],
   143              "additionalItems": { "type": "boolean" }
   144          },
   145          "tests": [
   146              {
   147                  "description": "items defined in allOf are not examined",
   148                  "data": [ 1, "hello" ],
   149                  "valid": false
   150              }
   151          ]
   152      },
   153      {
   154          "description": "items validation adjusts the starting index for additionalItems",
   155          "schema": {
   156              "items": [ { "type": "string" } ],
   157              "additionalItems": { "type": "integer" }
   158          },
   159          "tests": [
   160              {
   161                  "description": "valid items",
   162                  "data": [ "x", 2, 3 ],
   163                  "valid": true
   164              },
   165              {
   166                  "description": "wrong type of second item",
   167                  "data": [ "x", "y" ],
   168                  "valid": false
   169              }
   170          ]
   171      },
   172      {
   173          "description": "additionalItems with heterogeneous array",
   174          "schema": {
   175              "items": [{}],
   176              "additionalItems": false
   177          },
   178          "tests": [
   179              {
   180                  "description": "heterogeneous invalid instance",
   181                  "data": [ "foo", "bar", 37 ],
   182                  "valid": false
   183              },
   184              {
   185                  "description": "valid instance",
   186                  "data": [ null ],
   187                  "valid": true
   188              }
   189          ]
   190      },
   191      {
   192          "description": "additionalItems with null instance elements",
   193          "schema": {
   194              "additionalItems": {
   195                  "type": "null"
   196              }
   197          },
   198          "tests": [
   199              {
   200                  "description": "allows null elements",
   201                  "data": [ null ],
   202                  "valid": true
   203              }
   204          ]
   205      }
   206  ]