at: "npcs": { "$ref": "#/definitions/NpcEntry" }

change "npcs" to "items". npcs is not a valid keyword so it is ignored. The only validation that is happening is at the top level, verifying that the data is an object and that the one property is an array.

Answer from Ether on Stack Overflow
🌐
JSON Schema
json-schema.org › understanding-json-schema › reference › array
JSON Schema - array
The length of the array can be specified using the minItems and maxItems keywords. The value of each keyword must be a non-negative number. These keywords work whether doing list validation or tuple-validation.
🌐
PyPI
pypi.org › project › schema
schema · PyPI
Schema({}) becomes · {'type': 'object', 'properties' : {}, 'required': [], 'additionalProperties': False} Types · Use the Python type name directly. It will be converted to the JSON name: str -> string · int -> integer · float -> number · bool -> boolean · list -> array ·
      » pip install schema
    
Published   Oct 11, 2025
Version   0.7.8
🌐
GitHub
github.com › Julian › jsonschema › issues › 282
Items in array not validated · Issue #282 · python-jsonschema/jsonschema
I've been testing jsonschema to see if it will work my Python based API testing. I've hit a road block trying to figure out why this particular array is not being validated at all. It should be throwing a variety of failures, but does not. I've seen other arrays processed correctly but am not seeing why this specific one is not. import jsonschema schema = { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "pushNotifDevices" : { "type": "array", "description" : "", "items": { "applicationId": { "type": "boolean", "example":"CTS", "description":"This application ID identifies."
🌐
Opis
opis.io › json-schema › 2.x › array.html
Array type | Opis JSON Schema
An array is valid against this keyword if all unchecked items are valid against the schema defined by the keyword value. An item is considered unchecked if items keyword or prefixItems keyword (starting with draft 2020-12) contains an array of schemas and doesn’t have a corresponding position (index).
🌐
GitHub
github.com › Julian › jsonschema › issues › 148
"array" type should be (list, tuple) · Issue #148 · python-jsonschema/jsonschema
February 18, 2014 - Currently, it's impossible to use tuples as arrays, only lists. Array type should be a tuple like (list, tuple). default_types = { "array" : (list, tuple), "boolean" : bool, "integer" : int_types, ... or default_types = { "array" : array...
Author   igrishaev
🌐
Apache Arrow
arrow.apache.org › cookbook › py › schema.html
Working with Schema — Apache Arrow Python Cookbook documentation
import pyarrow as pa arr = pa.array([1, 2, 3, 4, 5]) print(arr.type) ... Tables detain multiple columns, each with its own name and type. The union of types and names is what defines a schema.
Find elsewhere
🌐
Built In
builtin.com › software-engineering-perspectives › python-json-schema
How to Use JSON Schema to Validate JSON Documents in Python | Built In
As we see, the schema definition for the tuple field with draft 2020–12 is more intuitive using the prefixItems and items keywords and thus is recommended to use. For a more detailed explanation of the changes from 2019–09 to 2020–12 regarding the tuple field definition, please review the release note. Besides, it should be noted that even if we want the scores field to be a tuple, it must be specified as an array (list in Python) rather than a tuple for the validator.
🌐
Cswr
cswr.github.io › JsonSchema › spec › arrays
Arrays - JSON Schema
First of all, we want to ensure that the document we are validating is an array using the type restriction. This is the basic array schema:
🌐
Readthedocs
python-jsonschema-objects.readthedocs.io › en › latest › Introduction.html
What — Python JSONSchema Objects 0.0.18 documentation
Literal values are wrapped when constructed to support validation and other schema-related operations. However, you can still use them just as you would other literals. >>> import python_jsonschema_objects as pjs >>> builder = pjs.ObjectBuilder(examples['Example Schema']) >>> ns = builder.build_classes() >>> Person = ns.ExampleSchema >>> james = Person(firstName="James", lastName="Bond") >>> str(james.lastName) 'Bond' >>> james.lastName += "ing" >>> str(james.lastName) 'Bonding' >>> james.age = 4 >>> james.age - 1 3 >>> 3 + james.age 7 >>> james.lastName / 4 Traceback (most recent call last): ...
🌐
Polars
docs.pola.rs › api › python › dev › reference › schema › index.html
Schema — Polars documentation
} ... ) >>> schema Schema({'foo': String, 'bar': Duration(time_unit='us'), 'baz': Array(Int8, shape=(4,))})
🌐
Readthedocs
py-avro-schema.readthedocs.io › en › stable › types.html
Supported data types — py-avro-schema documentation
Arbitrary lists of Python dictionaries could be serialized as a bytes Avro schema by first serializing the data as JSON.
🌐
JSON Schema
json-schema.org › understanding-json-schema › reference › type
JSON Schema - Type-specific Keywords
[1] Since JSON strings always support unicode, they are analogous to unicode on Python 2.x and str on Python 3.x. [2] JSON does not have separate types for integer and floating-point. ... A single string. When it is a single string, it must be one of the types mentioned above (array, boolean, integer, number, null, object, regular expressions, or string).
🌐
Tiledb
docs.tiledb.com › main › how-to › arrays › reading-arrays › reading-the-array-schema
Reading the Array Schema | TileDB Embedded Docs
// ... get array schema // Get array type tiledb_array_type_t array_type = schema.array_type(); // Get tile capacity uint64_t capacity = schema.capacity() // Get tile order tiledb_layout_t tile_order = schema.tile_order(); // Get cell order tiledb_layout_t cell_order = schema.cell_order(); // Get coordinates filter list FilterList filter_list = schema.coords_filter_list(); // Get offsets filter list FilterList filter_list = schema.offsets_filter_list(); // Get the array domain Domain domain = schema.domain(); // Get number of attributes uint32_t attr_num = schema.attribute_num(); // Get attrib
Top answer
1 of 2
3

You can only validate against one schema at a time, but that schema can reference ($ref) external schemas. These references are usually URIs that can be used to GET the schema. A filepath might work too if your schemas are not public. Using a fixed up version of your example, this would look something like this ...

http://your-domain.com/schema/person

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Person",
  "allOf": [{ "$ref": "http://your-domain.com/schema/base#" }],
  "properties": {
    "type": { "enum": ["person"] },
    "content": {
      "properties": {
        "address": { "$ref": "http://your-domain.com/schema/base#/definitions/location" }
      },
      "required": ["address"],
      "additionalProperties": false
    }
  }
}

http://your-domain.com/schema/base

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "base",
  "type": "object",
  "properties": {
    "content": { "type": "object" },
    "type": { "type": "string" }
  },
  "required": ["type", "content"],
  "additionalProperties": false,
  "definitions": {
    "location": {
      "type": "object",
      "properties": {
        "country": {
          "type": "string",
          "pattern": "^[A-Z]{2}$"
        },
        "name": { "type": "string" }
      },
      "required": ["name", "country"],
      "additionalProperties": false
    }
  }
}

Some documentation that might be useful

  • https://python-jsonschema.readthedocs.org/en/latest/validate/#the-validator-interface
  • https://python-jsonschema.readthedocs.org/en/latest/references/
2 of 2
0

Instead of hand coding a single schema from all your schemata, you can create a small schema which refers to the other schema files. This way you can use multiple existing JSONschema files and validate against them in combination:

import yaml
import jsonschema

A_yaml = """
id: http://foo/a.json
type: object
properties: 
    prop: 
        $ref: "./num_string.json"
"""

num_string_yaml = """
id: http://foo/num_string.json
type: string
pattern: ^[0-9]*$
"""

A = yaml.load(A_yaml)
num_string = yaml.load(num_string_yaml)

resolver = jsonschema.RefResolver("",None,
        store={
            "http://foo/A.json":A,
            "http://foo/num_string.json":num_string,
            })

validator = jsonschema.Draft4Validator(
        A, resolver=resolver)

try:
    validator.validate({"prop":"1234"})
    print "Properly accepted object"
except jsonschema.exceptions.ValidationError: 
    print "Failed to accept object"

try:
    validator.validate({"prop":"12d34"})
    print "Failed to reject object"
except jsonschema.exceptions.ValidationError: 
    print "Properly rejected object"

Note that you may want to combine the external using one of the schema cominators oneOf, allOf, or anyOf to combine your schemata like so:

[A.yaml]
oneOf:
     - $ref: "sub-schema1.json"
     - $ref: "sub-schema2.json"
     - $ref: "sub-schema3.json"
🌐
Frictionlessdata
framework.frictionlessdata.io › docs › fields › array.html
Array Field | Frictionless Framework
from frictionless import Schema, extract, fields data = [['name'], ['["value1", "value2"]']] rows = extract(data, schema=Schema(fields=[fields.ArrayField(name='name')])) print(rows) ... (*, name: str, title: Optional[str] = None, description: Optional[str] = None, format: str = default, missing_values: List[str] = NOTHING, constraints: Dict[str, Any] = NOTHING, rdf_type: Optional[str] = None, example: Optional[str] = None, schema: Optional[Schema] = None, array_item: Optional[Dict[str, Any]] = NOTHING) -> None