JsonSchemaModule

jsonschema. JsonSchemaModule

Module which add support for the JSON Schema specification

Constructor

new JsonSchemaModule()

Source:

Extends

  • AbstractModule

Members

schemaExtensions :Object

Source:
Temporary store of extension schemas
Type:
  • Object

schemas :Object

Source:
Reference to all registed schemas
Type:
  • Object

validator :external:Ajv

Source:
Reference to the Ajv instance
Type:
  • external:Ajv

xssWhitelist :Object

Source:
Tags and attributes to be whitelisted by the XSS filter
Type:
  • Object

Methods

addKeyword(definition)

Source:
Adds a new keyword to be used in JSON schemas
Parameters:
Name Type Description
definition AjvKeyword

addStringFormats()

Source:
Adds string formats to the Ajv validator

createSchema(filePath) → {JsonSchema}

Source:
Creates a new JsonSchema instance
Parameters:
Name Type Description
filePath String Path to the schema file
Returns:
Type
JsonSchema

deregisterSchema(name) → {Promise}

Source:
deregisters a single JSON schema
Parameters:
Name Type Description
name String Schem name to deregister
Returns:
Resolves with schema data
Type
Promise

extendSchema(baseSchemaName, extSchemaName)

Source:
Extends an existing schema with extra properties
Parameters:
Name Type Description
baseSchemaName String The name of the schema to extend
extSchemaName String The name of the schema to extend with

(async) getSchema(schemaName, options) → {Promise}

Source:
Retrieves the specified schema. Recursively applies any schema merge/patch schemas. Will returned cached data if enabled.
Parameters:
Name Type Description
schemaName String The name of the schema to return
options LoadSchemaOptions
Properties
Name Type Description
compiled Boolean If false, the raw schema will be returned
Returns:
The compiled schema validation function (default) or the raw schema
Type
Promise

(async) init()

Source:

(async) registerSchema(filePath, options) → {Promise}

Source:
Registers a single JSON schema for use in the app
Parameters:
Name Type Description
filePath String Path to the schema file
options RegisterSchemaOptions Extra options
Returns:
Type
Promise

(async) registerSchemas() → {Promise}

Source:
Searches all Adapt dependencies for any local JSON schemas and registers them for use in the app. Schemas must be located in in a `/schema` folder, and be named appropriately: `*.schema.json`.
Returns:
Type
Promise