openapi-metadata
Version:
Auto-Generate OpenAPI specifications from Typescript decorators
26 lines (22 loc) • 995 B
text/typescript
import { OpenAPIV3 } from 'openapi-types';
declare class Context {
schemas: Record<string, OpenAPIV3.SchemaObject>;
typeLoaders: TypeLoaderFn[];
logger: Logger;
constructor(logger?: Logger, typeLoaders?: TypeLoaderFn[]);
}
type HttpMethods = `${OpenAPIV3.HttpMethods}`;
type PrimitiveType = OpenAPIV3.NonArraySchemaObjectType;
type TypeValue = Function | PrimitiveType | [PrimitiveType | Function];
type Thunk<T> = (context: Context) => T;
type EnumTypeValue = string[] | number[] | Record<number, string>;
type Logger = {
warn: (typeof console)["warn"];
};
type TypeOptions = {
type?: Thunk<TypeValue> | TypeValue;
schema?: OpenAPIV3.SchemaObject;
enum?: EnumTypeValue;
};
type TypeLoaderFn = (context: Context, value: TypeValue, original?: Thunk<TypeValue> | TypeValue) => Promise<OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject | undefined>;
export type { HttpMethods as H, Logger as L, TypeLoaderFn as T, TypeValue as a, Thunk as b, TypeOptions as c };