UNPKG

1.62 kBTypeScriptView Raw
1import { TransformerFactory, SourceFile } from 'typescript';
2import SchemaId from './schemaId';
3import { JsonSchemaDraft04 } from './jsonSchemaDraft04';
4import { JsonSchemaDraft07 } from './jsonSchemaDraft07';
5export declare type JsonSchema = JsonSchemaDraft04.Schema | JsonSchemaDraft07.Schema;
6export declare type JsonSchemaObject = JsonSchemaDraft04.Schema | JsonSchemaDraft07.SchemaObject;
7export declare type SchemaType = 'Draft04' | 'Draft07';
8export interface Schema {
9 type: SchemaType;
10 openApiVersion?: 2 | 3;
11 id: SchemaId;
12 content: JsonSchema;
13 rootSchema?: Schema;
14}
15export declare function parseSchema(content: JsonSchema, url?: string): Schema;
16export declare function readSchemaFromStdin(): Promise<Schema>;
17export declare function readSchemasFromFile(pattern: string): Promise<Schema[]>;
18export declare function readSchemaFromUrl(url: string): Promise<Schema>;
19export declare function parseFileContent(content: string, filename?: string): JsonSchema;
20export interface PluginContext {
21 option: boolean | Record<string, unknown>;
22 inputSchemas: Iterator<[string, Schema]>;
23}
24export declare type PreProcessHandler = (contents: Schema[]) => Schema[];
25export declare type Plugin = {
26 meta: {
27 name: string;
28 version: string;
29 description?: string;
30 };
31 preProcess?: (context: PluginContext) => Promise<PreProcessHandler | undefined>;
32 postProcess?: (context: PluginContext) => Promise<TransformerFactory<SourceFile> | undefined>;
33};
34export declare function loadPlugin(name: string, option: boolean | Record<string, unknown>): Promise<Plugin | undefined>;