Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SchemaRepository

A repository is a holder of dereferenced schemas, it can be used to create validator instances for a specific schema.

This is to be used when multiple schema objects compose the global schema to be used for validation.

Hierarchy

  • SchemaRepository

Index

Methods

dereference

  • Dereferences a schema to the repository.

    Parameters

    Returns SchemaRepository

  • Dereferences a schema to the repository.

    Parameters

    Returns SchemaRepository

find

  • Look up a schema using a JSON pointer notation

    Parameters

    • pointer: string

    Returns JsonSchema

preloadMetaSchema

  • Preloads the repository with the meta schemas for the related @link Draft version. The related draft version is determined from the JsonSchemaOptions, in case that no draft is set in the options an IllegalStateException is thrown.

    Parameters

    • fs: FileSystem

    Returns SchemaRepository

  • Preloads the repository with the meta schemas for the related draft version.

    Parameters

    • fs: FileSystem
    • draft: Draft

    Returns SchemaRepository

resolve

  • resolve(schema: {}): {}
  • resolve(ref: string): {}
  • resolve(schema: JsonSchema): {}
  • Resolve all $ref in the given . The resolution algrithm is not aware of other specifications. When resolving OpenAPI documents (which only allow $ref at specific locations) you should validate if the document is valid before performing a resolution.

    It is important to note that any sibling elements of a $ref is ignored. This is because $ref works by replacing itself and everything on its level with the definition it is pointing at.

    Parameters

    • schema: {}
      • [key: string]: any

    Returns {}

    • [key: string]: any
  • Tries to resolve all internal and repository local references. External references are not resolved.

    The result is an object where all references have been resolved. Resolution of circular references is shallow. This should normally not be a problem for this use case.

    Parameters

    • ref: string

    Returns {}

    • [key: string]: any
  • Tries to resolve all internal and repository local references. External references are not resolved.

    The result is an object where all references have been resolved. Resolution of circular references is shallow. This should normally not be a problem for this use case.

    Parameters

    Returns {}

    • [key: string]: any

validator

  • A new validator instance using this repository options.

    Parameters

    Returns Validator

  • A new validator instance using this repository options. This is the preferred way to create a validator as it avoids reparsing schemas and reuses the cache in the repository.

    Parameters

    • ref: string

    Returns Validator

  • A new validator instance overriding this repository options. This is the preferred way to create a validator as it avoids reparsing schemas and reuses the cache in the repository.

    Parameters

    Returns Validator

  • A new validator instance overriding this repository options. The given schema will not be referenced to the repository.

    Parameters

    Returns Validator

  • A new validator instance overriding this repository options.

    Parameters

    Returns Validator

Static create

  • Create a repository with some initial configuration.

    Parameters

    Returns SchemaRepository

Generated using TypeDoc