@squiz/json-schema-library
Version:
Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation
18 lines (17 loc) • 832 B
TypeScript
import { Draft } from "../draft";
import { JSONSchema } from "../types";
/**
* compiles the input root schema for `$ref` resolution and returns it again
* @attention this modifies input schema but maintains data-structure and thus returns
* the same object with JSON.stringify
*
* for a compiled json-schema you can call getRef on any contained schema (location of type).
* this resolves a $ref target to a valid schema (for a valid $ref)
*
* @param draft
* @param schemaToCompile - json-schema to compile
* @param [rootSchema] - compiled root json-schema to use for definitions resolution
* @param [force] = false - force compile json-schema
* @return compiled input json-schema
*/
export default function compileSchema(draft: Draft, schemaToCompile: JSONSchema, rootSchema?: JSONSchema, force?: boolean): JSONSchema;