@opra/common
Version:
Opra common package
39 lines (38 loc) • 1.96 kB
TypeScript
import type { PartialSome, StrictOmit, ThunkAsync } from 'ts-gems';
import { OpraSchema } from '../../schema/index.js';
import { ApiDocument } from '../api-document.js';
import { DocumentInitContext } from '../common/document-init-context.js';
import { DataTypeFactory } from './data-type.factory.js';
import { HttpApiFactory } from './http-api.factory.js';
import { MQApiFactory } from './mq-api.factory.js';
import { WSApiFactory } from './ws-api.factory.js';
export declare namespace ApiDocumentFactory {
interface InitArguments extends PartialSome<StrictOmit<OpraSchema.ApiDocument, 'id' | 'references' | 'types' | 'api'>, 'spec'> {
references?: Record<string, ReferenceThunk>;
types?: DataTypeInitSources;
api?: StrictOmit<HttpApiFactory.InitArguments, 'owner'> | StrictOmit<MQApiFactory.InitArguments, 'owner'> | StrictOmit<WSApiFactory.InitArguments, 'owner'>;
}
type ReferenceSource = string | OpraSchema.ApiDocument | InitArguments | ApiDocument;
type ReferenceThunk = ThunkAsync<ReferenceSource>;
type DataTypeInitSources = DataTypeFactory.DataTypeSources;
}
/**
* @class ApiDocumentFactory
*/
export declare class ApiDocumentFactory {
private _allDocuments;
/**
* Creates ApiDocument instance from given schema object
*/
static createDocument(schemaOrUrl: string | PartialSome<OpraSchema.ApiDocument, 'spec'> | ApiDocumentFactory.InitArguments, options?: Partial<Pick<DocumentInitContext, 'maxErrors' | 'showErrorDetails'>> | DocumentInitContext): Promise<ApiDocument>;
/**
* Downloads schema from the given URL and creates the document instance * @param url
*/
protected initDocument(document: ApiDocument, context: DocumentInitContext, schemaOrUrl: ApiDocumentFactory.InitArguments | string): Promise<void>;
/**
*
* @param context
* @protected
*/
protected createBuiltinDocument(context: DocumentInitContext): Promise<ApiDocument>;
}