JsonSchemaModule

jsonschema. JsonSchemaModule

Module which add support for the JSON Schema specification

Constructor

new JsonSchemaModule()

Source:

Extends

  • AbstractModule

Members

schemaExtensions :Object

Description:
  • Temporary store of extension schemas
Source:
Temporary store of extension schemas
Type:
  • Object

schemas :Object

Description:
  • Reference to all registed schemas
Source:
Reference to all registed schemas
Type:
  • Object

validator :external:Ajv

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

xssWhitelist :Object

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

Methods

addKeyword(definition)

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

addStringFormats()

Description:
  • Adds string formats to the Ajv validator
Source:

createSchema(filePath) → {JsonSchema}

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

deregisterSchema(name) → {Promise}

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

extendSchema(baseSchemaName, extSchemaName)

Description:
  • Extends an existing schema with extra properties
Source:
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}

Description:
  • Retrieves the specified schema. Recursively applies any schema merge/patch schemas. Will returned cached data if enabled.
Source:
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}

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

(async) registerSchemas() → {Promise}

Description:
  • 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`.
Source:
Returns:
Type
Promise