Resolving JSON References¶
-
class
jsonschema.
RefResolver
(base_uri, referrer, store=(), cache_remote=True, handlers=(), urljoin_cache=None, remote_cache=None)[source]¶ Resolve JSON References.
Parameters: - base_uri (str) – URI of the referring document
- referrer – the actual referring document
- store (dict) – a mapping from URIs to documents to cache
- cache_remote (bool) – whether remote refs should be cached after first resolution
- handlers (dict) – a mapping from URI schemes to functions that should be used to retrieve them
Arguments functools.lru_cache urljoin_cache: a cache that will be used for caching the results of joining the resolution scope to subscopes.
Arguments functools.lru_cache remote_cache: a cache that will be used for caching the results of resolved remote URLs.
-
classmethod
from_schema
(schema, *args, **kwargs)[source]¶ Construct a resolver from a JSON schema object.
Parameters: schema – the referring schema Return type: RefResolver
-
resolve_fragment
(document, fragment)[source]¶ Resolve a
fragment
within the referenceddocument
.Parameters: - document – the referrant document
- fragment (str) – a URI fragment to resolve within it
-
resolve_remote
(uri)[source]¶ Resolve a remote
uri
.If called directly, does not check the store first, but after retrieving the document at the specified URI it will be saved in the store if
cache_remote
is True.Note
If the requests library is present,
jsonschema
will use it to request the remoteuri
, so that the correct encoding is detected and used.If it isn’t, or if the scheme of the
uri
is nothttp
orhttps
, UTF-8 is assumed.Parameters: uri (str) – the URI to resolve Returns: the retrieved document