Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SchemaRouter

Represents a pool where parsed schemas are addressed and cached.

It also contains a cache of including on top or inner level some json schemas that could eventually parsed later.

You should not share this object between different threads

Hierarchy

  • SchemaRouter

Index

Methods

addJson

  • Add one or more json documents including schemas on top or inner levels. This method doesn't trigger the schema parsing

    You can use this schema if you have externally loaded some json document and you want to register to the schema router. You can later parse and retrieve a schema from this json structure using , providing the correct refPointer

    Parameters

    • uri: string
    • object: {}
      • [key: string]: any

    Returns SchemaRouter

  • Add one or more json documents including schemas on top or inner levels. This method doesn't trigger the schema parsing

    You can use this schema if you have externally loaded some json document and you want to register to the schema router. You can later parse and retrieve a schema from this json structure using , providing the correct refPointer

    Parameters

    • uri: any
    • object: {}
      • [key: string]: any

    Returns SchemaRouter

addSchema

  • Add a parsed schema to this router. When a schema is added to the cache, a new entry is created for {@link Schema#getScope} and, if you provide additional aliasScopes, this method register links to this schema with these scopes. This method is automatically called by SchemaParser when a new schema is parsed

    Parameters

    • schema: Schema
    • aliasScopes: any

    Returns SchemaRouter

addSchemaAlias

  • Add an alias to a schema already registered in this router (this alias can be solved only from schema scope).

    Parameters

    • schema: Schema
    • alias: string

    Returns SchemaRouter

addSchemaWithScope

  • Add a parsed schema to this router. When a schema is added to the cache, a new entry is created for the provided scope, but NOT for {@link Schema#getScope}. This may be useful to register links to singleton schemas. This method is automatically called by SchemaParser when a new schema is parsed

    Parameters

    • schema: Schema
    • scope: JsonPointer

    Returns SchemaRouter

registeredSchemas

  • Returns Schema

resolveCachedSchema

  • resolveCachedSchema(refPointer: JsonPointer, schemaScope: JsonPointer, parser: SchemaParser): Schema | null
  • Resolve cached schema based on refPointer. If a schema isn't cached, it returns null

    Parameters

    • refPointer: JsonPointer
    • schemaScope: JsonPointer
    • parser: SchemaParser

    Returns Schema | null

resolveRef

  • resolveRef(pointer: JsonPointer, scope: JsonPointer, schemaParser: SchemaParser): PromiseLike<Schema>
  • resolveRef(pointer: JsonPointer, scope: JsonPointer, schemaParser: SchemaParser, handler: ((res: AsyncResult<Schema>) => void) | Handler<AsyncResult<Schema>>): void
  • Like {@link SchemaRouter#resolveRef} but with a direct callback.

    Parameters

    • pointer: JsonPointer
    • scope: JsonPointer
    • schemaParser: SchemaParser

    Returns PromiseLike<Schema>

  • Like {@link SchemaRouter#resolveRef} but with a direct callback.

    Parameters

    • pointer: JsonPointer
    • scope: JsonPointer
    • schemaParser: SchemaParser
    • handler: ((res: AsyncResult<Schema>) => void) | Handler<AsyncResult<Schema>>

    Returns void

Static create

Generated using TypeDoc