UNPKG

openapi-alchemist

Version:

Transform OpenAPI 3 to Swagger 2 with alchemical precision

67 lines (66 loc) 2.3 kB
export interface ConvertOptions { from: 'openapi_3'; to: 'swagger_2' | 'openapi_3'; source: string | object; syntax?: 'json' | 'yaml'; order?: 'openapi' | 'alpha' | 'false'; passthrough?: any; } export interface ConvertResult { spec: any; stringify(options?: StringifyOptions): string; } export interface StringifyOptions { syntax?: 'json' | 'yaml'; order?: 'openapi' | 'alpha' | 'false'; } export interface ValidationResult { errors: any[] | null; warnings: any[] | null; } export interface ResourceReaders { file: (filename: string) => Promise<string>; object: (data: any) => Promise<any>; string: (data: string) => Promise<string>; } export declare abstract class BaseFormat { spec: any; format: string; converters: { [key: string]: (spec: BaseFormat, passthrough?: any) => Promise<any>; }; sourceType?: string; source?: string; subResources?: { [key: string]: any; }; constructor(spec?: any); abstract formatName: string; abstract supportedVersions: string[]; abstract getFormatVersion(): string; abstract checkFormat(spec: any): boolean; stringify(options?: StringifyOptions): string; fillMissing(_dummyData?: any): void; validate(callback?: (err: any, result: ValidationResult) => void): Promise<ValidationResult>; listSubResources(): { [key: string]: string; }; resolveSubResources(): Promise<void>; parse(data: any): Promise<any>; readSpec(source: string | object): Promise<[any, string]>; resolveResources(source: string | object): Promise<void>; convertTo(format: string, passthrough?: any, callback?: (err: any, result: BaseFormat) => void): Promise<BaseFormat>; convertTransitive(intermediaries: string[], passthrough?: any): Promise<any>; protected abstract parsers: { [key: string]: (data: string) => Promise<any>; }; protected abstract fixSpec(): void; } export declare class Util { static joinPath(...args: string[]): string; static parseJSON: (data: string) => Promise<any>; static parseYAML: (data: string) => Promise<any>; static resourceReaders: ResourceReaders; static getSourceType(source: any): string | undefined; static removeNonValues(obj: any): void; }