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 (jschon.jsonschema.JSONSchema) –

  • key (str) –

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

Return type

Optional[jschon.json.JSON]

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

  • value (JSONCompatible) –

__init__(parentschema, value)
Parameters
can_evaluate(instance)
Parameters

instance (jschon.json.JSON) –

Return type

bool

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', 'integer', 'number', 'string', 'array', 'object')

The types of instance that the keyword can evaluate.

key: str = Ellipsis
static: bool = False
class jschon.vocabulary.Metaschema(catalog, value, core_vocabulary, *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.

__init__(catalog, value, core_vocabulary, *default_vocabularies, **kwargs)
Parameters
  • catalog (Catalog) –

  • value (Mapping[str, JSONCompatible]) –

  • core_vocabulary (Vocabulary) –

  • default_vocabularies (Vocabulary) –

  • kwargs (Any) –

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[jschon.vocabulary.Keyword]

cacheid: Hashable

Schema cache identifier.

catalog: Catalog

The catalog in which the schema is cached.

data: Union[None, bool, int, float, str, List[JSON], Dict[str, JSON]]

The schema data.

JSON type

data type

boolean

bool

object

dict[str, JSON]

itemclass: Type[JSON]

The JSON class type of child instances.

itemkwargs: Dict[str, Any]

Keyword arguments to the itemclass constructor.

key: Optional[str]

The index of the schema within its parent.

keywords: Dict[str, Keyword]

A dictionary of the schema’s Keyword objects, indexed by keyword name.

parent: Optional[JSON]

The containing JSON or JSONSchema node.

type: str

The JSON type of the schema. One of "boolean", "object".

class jschon.vocabulary.ObjectOfSubschemas

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

classmethod jsonify(parentschema, key, value)
Parameters
  • parentschema (jschon.jsonschema.JSONSchema) –

  • key (str) –

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

Return type

Optional[jschon.json.JSON]

class jschon.vocabulary.Subschema

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

classmethod jsonify(parentschema, key, value)
Parameters
  • parentschema (jschon.jsonschema.JSONSchema) –

  • key (str) –

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

Return type

Optional[jschon.json.JSON]

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

  • key (str) –

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

Return type

Optional[jschon.json.JSON]

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