UNPKG

api-ref-bundler

Version:

Bundle all external $ref in Json based API document into single document

21 lines (20 loc) 838 B
import { JsonPath, CrawlContext, CloneState } from "json-crawl"; import { Resolver } from "./resolver"; import { DereferenceState } from "./dereference"; import { RefMapRules } from "./types"; export interface BundleState extends DereferenceState { defPrefix?: string; path: JsonPath; } export type BundleContext = CrawlContext<CloneState<BundleState>, RefMapRules>; export interface BundleOptions { ignoreSibling?: boolean; hooks?: { onError?: (message: string, ctx: BundleContext) => void; onRef?: (ref: string, ctx: BundleContext) => void; onCrawl?: (value: any, ctx: BundleContext) => void; onExit?: (value: any, ctx: BundleContext) => void; }; rules?: RefMapRules; } export declare const bundle: (baseFile: string, resolver: Resolver, options?: BundleOptions) => Promise<any>;