UNPKG

@open-rpc/schema-utils-js

Version:

<center> <span> <img alt="CircleCI branch" src="https://img.shields.io/circleci/project/github/open-rpc/schema-utils-js/master.svg"> <img src="https://codecov.io/gh/open-rpc/schema-utils-js/branch/master/graph/badge.svg" /> <img alt="npm" sr

43 lines (42 loc) 1.31 kB
import { OpenrpcDocument as OpenRPC } from "@open-rpc/meta-schema"; import referenceResolver from "@json-schema-tools/reference-resolver"; export type ReferenceResolver = typeof referenceResolver; /** * Provides an error interface for OpenRPC Document dereferencing problems * * @category Errors * */ export declare class OpenRPCDocumentDereferencingError implements Error { name: string; message: string; /** * @param e The error that originated from jsonSchemaRefParser */ constructor(e: string); } /** * replaces $ref's within a document and its schemas. The replaced value will be a javascript object reference to the * real schema / open-rpc component * * @param schema The OpenRPC document * * @returns The same OpenRPC Document that was passed in, but with all $ref's dereferenced. * * @throws [[OpenRPCDocumentDereferencingError]] * * @example * ```typescript * * import { OpenRPC } from "@open-rpc/meta-schema" * import { dereferenceDocument } from "@open-rpc/schema-utils-js"; * * try { * const dereffedDocument = await dereferenceDocument({ ... }) as OpenRPC; * } catch (e) { * // handle validation errors * } * ``` * */ export default function dereferenceDocument(openrpcDocument: OpenRPC, resolver?: ReferenceResolver): Promise<OpenRPC>;