Constructor
new JsonSchemaModule()
- Source:
Extends
Members
_library :Schemas
- Description:
- Internal schema library instance
- Source:
Internal schema library instance
Type:
registerSchemasHook :Hook
- Description:
- Invoked when schemas are registered
- Source:
Invoked when schemas are registered
Type:
schemaExtensions :Object
- Description:
- Temporary store of extension schemas
- Source:
Temporary store of extension schemas
Type:
schemas :Object
- Description:
- Reference to all registered schemas
- Source:
Reference to all registered schemas
Type:
validator :external:Ajv
- Description:
- Reference to the Ajv instance
- Source:
Reference to the Ajv instance
Type:
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:
Methods
addKeyword(definition, options)
- Description:
- Adds a new keyword to be used in JSON schemas
- Source:
Parameters:
| Name |
Type |
Description |
definition |
Object
|
AJV keyword definition |
options |
Object
|
Configuration options
Properties
| Name |
Type |
Description |
override |
Boolean
|
Whether to override an existing definition |
|
- Description:
- Adds string formats to the Ajv validator
- Source:
Parameters:
| Name |
Type |
Description |
formats |
Object
|
Object mapping format names to RegExp patterns |
createSchema(filePath, options) → {Promise.<Schema>}
- Description:
- Creates a new Schema instance
- Source:
Parameters:
| Name |
Type |
Description |
filePath |
String
|
Path to the schema file |
options |
Object
|
Options passed to Schema constructor |
Returns:
-
Type
-
Promise.<Schema>
deregisterSchema(name)
- Description:
- Deregisters a single JSON schema
- Source:
Parameters:
| Name |
Type |
Description |
name |
String
|
Schema name to deregister |
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.<Schema>}
- Description:
- Retrieves the specified schema. Recursively applies any schema merge/patch schemas.
Will return cached data if enabled.
- Source:
Parameters:
| Name |
Type |
Description |
schemaName |
String
|
The name of the schema to return |
options |
Object
|
Properties
| Name |
Type |
Description |
compiled |
Boolean
|
If false, the raw schema will be returned |
|
Returns:
The schema instance
-
Type
-
Promise.<Schema>
(async) init()
- Source:
logSchemas()
- Description:
- Logs all registered schemas & schema extensions
- Source:
(async) registerSchema(filePath, options) → {Promise.<Schema>}
- Description:
- Registers a single JSON schema for use in the app
- Source:
Parameters:
| Name |
Type |
Description |
filePath |
String
|
Path to the schema file |
options |
Object
|
Extra options
Properties
| Name |
Type |
Description |
replace |
Boolean
|
Replace existing schema with same name |
|
Returns:
-
Type
-
Promise.<Schema>
(async) registerSchemas(options) → {Promise}
- Description:
- Searches all Adapt dependencies for any local JSON schemas and registers them for use in the app.
Schemas must be located in a `/schema` folder, and be named appropriately: `*.schema.json`.
- Source:
Parameters:
| Name |
Type |
Description |
options |
Object
|
Properties
| Name |
Type |
Description |
quiet |
Boolean
|
Set to true to suppress logs |
|
Returns:
-
Type
-
Promise
(async) resetSchemaRegistry()
- Description:
- Empties the schema registry (with the exception of the base schema)
- Source: