Skip to main content

@versionzero/schema / SchemaResolver

Class: SchemaResolver

Defined in: src/schema-resolver.js:49

The SchemaResolver uses its internal registries of named schemas and value processor keywords to convert Schemas containing unresolved references into resolved Schemas that are fully self-contained.

Methods

registerSchema()

registerSchema(name, schema): SchemaResolver

Defined in: src/schema-resolver.js:75

add a schema to the registry

Parameters

ParameterTypeDescription
namestring-
schemaSchema-

Returns

SchemaResolver


getSchema()

getSchema(name): Schema

Defined in: src/schema-resolver.js:89

return the registered schema with a given name

Parameters

ParameterTypeDescription
namestring-

Returns

Schema


hasSchema()

hasSchema(name): boolean

Defined in: src/schema-resolver.js:103

return true if there exists a registered schema with a given name

Parameters

ParameterTypeDescription
namestring-

Returns

boolean


registerValueProcessorDefinition()

registerValueProcessorDefinition(definition): SchemaResolver

Defined in: src/schema-resolver.js:113

Register a value processor definition

Parameters

ParameterTypeDescription
definitionValueProcessorDefinition-

Returns

SchemaResolver


registerValueProcessor()

registerValueProcessor(keyword, process, description?): SchemaResolver

Defined in: src/schema-resolver.js:143

register a named "simple" ValueProcessor

Parameters

ParameterTypeDescription
keywordstring-
processValueProcessorFunction-
description?string-

Returns

SchemaResolver


registerValueProcessorBuilder()

registerValueProcessorBuilder(keyword, build): SchemaResolver

Defined in: src/schema-resolver.js:161

register a complex ValueProcessor that needs to be built based on schema processor spec

Parameters

ParameterTypeDescription
keywordstring-
buildValueProcessorBuilder-

Returns

SchemaResolver


compileKeywordValueProcessorSpec()

compileKeywordValueProcessorSpec(compiler, spec, recursive?): ValueProcessor

Defined in: src/schema-resolver.js:209

Parameters

ParameterTypeDescription
compilerSchemaCompiler-
specKeywordValueProcessorSpec-
recursive?boolean-

Returns

ValueProcessor


compileValueProcessorSpecObject()

compileValueProcessorSpecObject(compiler, spec, recursive?): ValueProcessor

Defined in: src/schema-resolver.js:271

Convert a processor specification into an executor

Parameters

ParameterTypeDefault valueDescription
compilerSchemaCompilerundefined-
specanyundefinedThe processor specification
recursive?booleanfalse-

Returns

ValueProcessor


compileValueProcessorSpecArray()

compileValueProcessorSpecArray(compiler, spec, recursive?): ValueProcessor

Defined in: src/schema-resolver.js:292

Convert a processor specification into an executor

Parameters

ParameterTypeDefault valueDescription
compilerSchemaCompilerundefined-
specanyundefinedThe processor specification
recursive?booleanfalse-

Returns

ValueProcessor


compileValueProcessorSpec()

compileValueProcessorSpec(compiler, spec, recursive?): ValueProcessor

Defined in: src/schema-resolver.js:314

Convert a value processor specification into a value processor executor

Parameters

ParameterTypeDefault valueDescription
compilerSchemaCompilerundefined-
specanyundefinedThe processor specification
recursive?booleanfalse-

Returns

ValueProcessor


compile()

compile(inputSchema): Promise<CompiledSchema>

Defined in: src/schema-resolver.js:405

Build a compiled schema from the schema definition.

Parameters

ParameterTypeDescription
inputSchemaCompiledSchema | SchemaData | Schema-

Returns

Promise<CompiledSchema>


resolve()

resolve(inputSchema, recursive?): CompiledSchema | Schema

Defined in: src/schema-resolver.js:423

Create a new Schema that contains the flattened hierarchy of all resolved base schemas.

This can be useful if you need to make changes to the full schema, e.g. prepending processors before the base class handlers.

Parameters

ParameterTypeDefault valueDescription
inputSchemastring | CompiledSchema | SchemaData | Schemaundefined-
recursive?booleantrue-

Returns

CompiledSchema | Schema