Skip to content
Francis Galiegue edited this page Apr 1, 2014 · 4 revisions

Goal

Define a coherent loading strategy and matching API.

Use a set of options for loading schemas according to the user's need.

Features

  • Have "anonymous", rootless schemas.
  • Preload schemas at absolute JSON References only (URI has a scheme; no fragment or an empty fragment).
  • Give the possibility to use the top level "id" only if absolute and the schema is not loaded via a URI.
  • Enable or disable caching.
  • Give the possibility to use inline dereferencing.

Options

Proposed name: interface SchemaLoadingOption; implementation: DefaultSchemaLoadingOption.*

REJECT_DUPLICATE_OBJECT_MEMBERS (true by default)

RFC 7159 does not explicitly reject such stuff; but it is ill-formed JSON.

USE_TOPLEVEL_ID_AS_URI (false by default)

If a schema is loaded anonymously, and a top level "id" is found is a valid, absolute JSON Reference, then the schema is loaded in cache using that URI.

USE_INLINE_DEREFERENCING (false by default)

If the schema redefines the context by using embedded "id"s, then the schema is authoritative for that URI context as soon as the validation process stays within this schema. Otherwise the normal loading procedure takes place.

DISABLE_SCHEMA_CACHING (false by default)

If this option is defined, schemas will not be cached and will be reloaded each time.

PRELOAD_URI_CONFLICT_RAISES_EXCEPTION (enabled by default)

If a schema is preloaded using a URI but the schema has an absolute, valid JSON Reference at top level, and this URI differs from the request URI, an unchecked exception is raised.

ILLEGAL_JSON_REFERENCE_RAISES_EXCEPTION (enabled by default)

If a load request for a URI which is not a valid JSON Reference (that is, its fragment part, if any, is not a JSON Pointer), the load request fails with an unchecked exception.

API

JsonSchemaLoaderFactory

Factory to create all components below.

JsonSchemaLoader

Abstract class (or interface?). Methods:

  • load(JsonNode): load a schema anonymously;
  • preload(URI, JsonNode): preload a schema at a given URI;
  • load(URI): load a schema at a given URI; possibly a reference, and possibly with a fragment part.

UriTransformer

Inside a JsonSchemaLoader. Takes care of namespace/schema redirections etc. Interface?

JsonReferenceResolver

Within, and uses, a JsonSchemaLoader. Is in charge of full JSON Reference resolution, conflict detection etc. Interface?

Other links

ni: URI: neat, but expensive.