@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
| Parameter | Type | Description |
|---|---|---|
name | string | - |
schema | Schema | - |
Returns
SchemaResolver
getSchema()
getSchema(
name):Schema
Defined in: src/schema-resolver.js:89
return the registered schema with a given name
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | - |
Returns
hasSchema()
hasSchema(
name):boolean
Defined in: src/schema-resolver.js:103
return true if there exists a registered schema with a given name
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | - |
Returns
boolean
registerValueProcessorDefinition()
registerValueProcessorDefinition(
definition):SchemaResolver
Defined in: src/schema-resolver.js:113
Register a value processor definition
Parameters
| Parameter | Type | Description |
|---|---|---|
definition | ValueProcessorDefinition | - |
Returns
SchemaResolver
registerValueProcessor()
registerValueProcessor(
keyword,process,description?):SchemaResolver
Defined in: src/schema-resolver.js:143
register a named "simple" ValueProcessor
Parameters
| Parameter | Type | Description |
|---|---|---|
keyword | string | - |
process | ValueProcessorFunction | - |
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
| Parameter | Type | Description |
|---|---|---|
keyword | string | - |
build | ValueProcessorBuilder | - |
Returns
SchemaResolver
compileKeywordValueProcessorSpec()
compileKeywordValueProcessorSpec(
compiler,spec,recursive?):ValueProcessor
Defined in: src/schema-resolver.js:209
Parameters
| Parameter | Type | Description |
|---|---|---|
compiler | SchemaCompiler | - |
spec | KeywordValueProcessorSpec | - |
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
compiler | SchemaCompiler | undefined | - |
spec | any | undefined | The processor specification |
recursive? | boolean | false | - |
Returns
ValueProcessor
compileValueProcessorSpecArray()
compileValueProcessorSpecArray(
compiler,spec,recursive?):ValueProcessor
Defined in: src/schema-resolver.js:292
Convert a processor specification into an executor
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
compiler | SchemaCompiler | undefined | - |
spec | any | undefined | The processor specification |
recursive? | boolean | false | - |
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
compiler | SchemaCompiler | undefined | - |
spec | any | undefined | The processor specification |
recursive? | boolean | false | - |
Returns
ValueProcessor
compile()
compile(
inputSchema):Promise<CompiledSchema>
Defined in: src/schema-resolver.js:405
Build a compiled schema from the schema definition.
Parameters
| Parameter | Type | Description |
|---|---|---|
inputSchema | CompiledSchema | 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
| Parameter | Type | Default value | Description |
|---|---|---|---|
inputSchema | string | CompiledSchema | SchemaData | Schema | undefined | - |
recursive? | boolean | true | - |