UNPKG

2.04 kBTypeScriptView Raw
1import { TransformerFactory, SourceFile } from 'typescript';
2import { JsonSchemaDraft04 } from './jsonSchemaDraft04';
3import { JsonSchemaDraft07 } from './jsonSchemaDraft07';
4import { OpenApisV2 } from './openApiV2';
5import { OpenApisV3 } from './openApiV3';
6import SchemaId from './schemaId';
7export import ts = require('typescript');
8export declare type JsonSchema = JsonSchemaDraft04.Schema | JsonSchemaDraft07.Schema;
9export declare type JsonSchemaObject = JsonSchemaDraft04.Schema | JsonSchemaDraft07.SchemaObject;
10export declare type SchemaType = 'Draft04' | 'Draft07' | '2019-09' | '2020-12' | 'Latest';
11export declare function isJsonSchemaDraft04(_content: JsonSchemaObject, type: SchemaType): _content is JsonSchemaDraft04.Schema;
12export declare type $Ref = OpenApisV3.SchemaJson.Definitions.Reference | OpenApisV2.SchemaJson.Definitions.JsonReference;
13export interface Schema {
14 type: SchemaType;
15 openApiVersion?: 2 | 3;
16 id: SchemaId;
17 content: JsonSchema;
18 rootSchema?: Schema;
19}
20export declare function parseSchema(content: JsonSchema, url?: string): Schema;
21export declare function readSchemaFromStdin(): Promise<Schema>;
22export declare function readSchemasFromFile(pattern: string): Promise<Schema[]>;
23export declare function readSchemaFromUrl(url: string): Promise<Schema>;
24export declare function parseFileContent(content: string, filename?: string): JsonSchema;
25export interface PluginContext {
26 option: boolean | Record<string, unknown>;
27 inputSchemas: IterableIterator<[string, Schema]>;
28}
29export declare type PreProcessHandler = (contents: Schema[]) => Schema[];
30export declare type Plugin = {
31 meta: {
32 name: string;
33 version: string;
34 description?: string;
35 };
36 preProcess?: (context: PluginContext) => Promise<PreProcessHandler | undefined>;
37 postProcess?: (context: PluginContext) => Promise<TransformerFactory<SourceFile> | undefined>;
38};
39export declare function loadPlugin(name: string, option: boolean | Record<string, unknown>): Promise<Plugin | undefined>;