jschon.vocabulary

class jschon.vocabulary.ArrayOfSubschemas

A Keyword class mixin that sets up an array of subschemas for a keyword.

classmethod jsonify(parentschema, key, value)
Parameters:
  • parentschema (JSONSchema) –

  • key (str) –

  • value (None | bool | int | float | str | Sequence[Any] | Mapping[str, Any]) –

Return type:

JSON | None

class jschon.vocabulary.Keyword(parentschema, value)
Parameters:
  • parentschema (JSONSchema) –

  • value (JSONCompatible) –

__init__(parentschema, value)
Parameters:
  • parentschema (JSONSchema) –

  • value (None | bool | int | float | str | Sequence[Any] | Mapping[str, Any]) –

evaluate(instance, result)
Parameters:
Return type:

None

depends_on: Tuple[str, ...] = ()

Keywords that must be evaluated before this keyword can be evaluated.

instance_types: Tuple[str, ...] = ('null', 'boolean', 'number', 'string', 'array', 'object')

The types of instance that the keyword can evaluate.

key: str = Ellipsis

The keyword name as it appears in a schema object.

static: bool = False

static = True (equivalent to instance_types = ()) indicates that the keyword does not ever evaluate any instance.

class jschon.vocabulary.Metaschema(catalog, value, default_core_vocabulary=None, *default_vocabularies, **kwargs)

A metaschema declares the set of vocabularies that are available to any schema which references it, and provides any such schema with its Keyword classes.

Metaschema is itself a subclass of JSONSchema, and may be used to validate any referencing schema.

Parameters:
  • catalog (Catalog) –

  • value (Mapping[str, JSONCompatible]) –

  • default_core_vocabulary (Vocabulary) –

  • default_vocabularies (Vocabulary) –

  • kwargs (Any) –

__init__(catalog, value, default_core_vocabulary=None, *default_vocabularies, **kwargs)

Initialize a Metaschema instance from the given schema-compatible value.

Parameters:
  • catalog (Catalog) – catalog instance

  • value (Mapping[str, JSONCompatible]) – a schema-compatible Python object

  • default_core_vocabulary (Vocabulary) – the metaschema’s core Vocabulary, used in the absence of a "$vocabulary" keyword in the metaschema JSON file, or if a known core vocabulary is not present under "$vocabulary"

  • default_vocabulary – default Vocabulary instances, used in the absence of a "$vocabulary" keyword in the metaschema JSON file

  • kwargs (Any) – additional keyword arguments to pass through to the JSONSchema constructor

  • default_vocabularies (Vocabulary) –

Raises:
get_kwclass(key)

Return the Keyword class this metaschema uses for the given key. If the key is not recognized, a subclass of an internal Keyword subclass that treats the keyword as a simple annotation is automatically created, associated with the key, and returned.

Parameters:

key (str) –

Return type:

Type[Keyword]

class jschon.vocabulary.ObjectOfSubschemas

A Keyword class mixin that sets up property-based subschemas for a keyword.

classmethod jsonify(parentschema, key, value)
Parameters:
  • parentschema (JSONSchema) –

  • key (str) –

  • value (None | bool | int | float | str | Sequence[Any] | Mapping[str, Any]) –

Return type:

JSON | None

class jschon.vocabulary.Subschema

A Keyword class mixin that sets up a subschema for a keyword.

classmethod jsonify(parentschema, key, value)
Parameters:
  • parentschema (JSONSchema) –

  • key (str) –

  • value (None | bool | int | float | str | Sequence[Any] | Mapping[str, Any]) –

Return type:

JSON | None

class jschon.vocabulary.SubschemaMixin
classmethod jsonify(parentschema, key, value)
Parameters:
  • parentschema (JSONSchema) –

  • key (str) –

  • value (None | bool | int | float | str | Sequence[Any] | Mapping[str, Any]) –

Return type:

JSON | None

class jschon.vocabulary.Vocabulary(uri, *kwclasses)

A vocabulary declares a set of keywords that may be used in the evaluation of JSON documents, and provides a runtime implementation (in the form of a Keyword class) for each of those keywords.

Parameters:
  • uri (URI) –

  • kwclasses (KeywordClass) –

__init__(uri, *kwclasses)
Parameters: