Skip to content

schema

Wrapper around :mod:jsonschema

Schemas are implicitly loaded from the /schema directory of this project.

Attributes:

Name Type Description
_cache

Cache of previously loaded schemas

Resources

http://json-schema.org/ http://json-schema.org/latest/json-schema-core.html http://spacetelescope.github.io/understanding-json-schema/index.html

validate(data, schema=None)

Validate data with schema

Parameters:

Name Type Description Default
data dict

JSON-compatible data

required
schema str

DEPRECATED Name of schema. Now included in the data.

None
Source code in client/ayon_core/pipeline/schema/__init__.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
def validate(data, schema=None):
    """Validate `data` with `schema`

    Arguments:
        data (dict): JSON-compatible data
        schema (str): DEPRECATED Name of schema. Now included in the data.

    Raises:
        ValidationError on invalid schema

    """
    if not _CACHED:
        _precache()

    root, schema = data["schema"].rsplit(":", 1)

    if isinstance(schema, str):
        schema = _cache[schema + ".json"]

    resolver = jsonschema.RefResolver(
        "",
        None,
        store=_cache,
        cache_remote=True
    )

    jsonschema.validate(data,
                        schema,
                        types={"array": (list, tuple)},
                        resolver=resolver)