github.com/kaptinlin/jsonschema@v0.4.6/testdata/JSON-Schema-Test-Suite/tests/draft4/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              "additionalItems": false
    26          },
    27          "tests": [
    28              {
    29                  "description": "all items match schema",
    30                  "data": [ 1, 2, 3, 4, 5 ],
    31                  "valid": true
    32              }
    33          ]
    34      },
    35      {
    36          "description": "array of items with no additionalItems permitted",
    37          "schema": {
    38              "items": [{}, {}, {}],
    39              "additionalItems": false
    40          },
    41          "tests": [
    42              {
    43                  "description": "empty array",
    44                  "data": [ ],
    45                  "valid": true
    46              },
    47              {
    48                  "description": "fewer number of items present (1)",
    49                  "data": [ 1 ],
    50                  "valid": true
    51              },
    52              {
    53                  "description": "fewer number of items present (2)",
    54                  "data": [ 1, 2 ],
    55                  "valid": true
    56              },
    57              {
    58                  "description": "equal number of items present",
    59                  "data": [ 1, 2, 3 ],
    60                  "valid": true
    61              },
    62              {
    63                  "description": "additional items are not permitted",
    64                  "data": [ 1, 2, 3, 4 ],
    65                  "valid": false
    66              }
    67          ]
    68      },
    69      {
    70          "description": "additionalItems as false without items",
    71          "schema": {"additionalItems": false},
    72          "tests": [
    73              {
    74                  "description":
    75                      "items defaults to empty schema so everything is valid",
    76                  "data": [ 1, 2, 3, 4, 5 ],
    77                  "valid": true
    78              },
    79              {
    80                  "description": "ignores non-arrays",
    81                  "data": {"foo" : "bar"},
    82                  "valid": true
    83              }
    84          ]
    85      },
    86      {
    87          "description": "additionalItems are allowed by default",
    88          "schema": {"items": [{"type": "integer"}]},
    89          "tests": [
    90              {
    91                  "description": "only the first item is validated",
    92                  "data": [1, "foo", false],
    93                  "valid": true
    94              }
    95          ]
    96      },
    97      {
    98          "description": "additionalItems does not look in applicators, valid case",
    99          "schema": {
   100              "allOf": [
   101                  { "items": [ { "type": "integer" } ] }
   102              ],
   103              "additionalItems": { "type": "boolean" }
   104          },
   105          "tests": [
   106              {
   107                  "description": "items defined in allOf are not examined",
   108                  "data": [ 1, null ],
   109                  "valid": true
   110              }
   111          ]
   112      },
   113      {
   114          "description": "additionalItems does not look in applicators, invalid case",
   115          "schema": {
   116              "allOf": [
   117                  { "items": [ { "type": "integer" }, { "type": "string" } ] }
   118              ],
   119              "items": [ {"type": "integer" } ],
   120              "additionalItems": { "type": "boolean" }
   121          },
   122          "tests": [
   123              {
   124                  "description": "items defined in allOf are not examined",
   125                  "data": [ 1, "hello" ],
   126                  "valid": false
   127              }
   128          ]
   129      },
   130      {
   131          "description": "items validation adjusts the starting index for additionalItems",
   132          "schema": {
   133              "items": [ { "type": "string" } ],
   134              "additionalItems": { "type": "integer" }
   135          },
   136          "tests": [
   137              {
   138                  "description": "valid items",
   139                  "data": [ "x", 2, 3 ],
   140                  "valid": true
   141              },
   142              {
   143                  "description": "wrong type of second item",
   144                  "data": [ "x", "y" ],
   145                  "valid": false
   146              }
   147          ]
   148      },
   149      {
   150          "description": "additionalItems with heterogeneous array",
   151          "schema": {
   152              "items": [{}],
   153              "additionalItems": false
   154          },
   155          "tests": [
   156              {
   157                  "description": "heterogeneous invalid instance",
   158                  "data": [ "foo", "bar", 37 ],
   159                  "valid": false
   160              },
   161              {
   162                  "description": "valid instance",
   163                  "data": [ null ],
   164                  "valid": true
   165              }
   166          ]
   167      },
   168      {
   169          "description": "additionalItems with null instance elements",
   170          "schema": {
   171              "additionalItems": {
   172                  "type": "null"
   173              }
   174          },
   175          "tests": [
   176              {
   177                  "description": "allows null elements",
   178                  "data": [ null ],
   179                  "valid": true
   180              }
   181          ]
   182      }
   183  ]