import 'reflect-metadata'; import type { TPath, TOperation } from '@avanzu/oas-builder'; import type { Endpoint, MountPoint } from './routing'; import type { InfoBlock } from '../modules/documentation'; import type { Constructor } from './util'; import { StatusCodes } from 'http-status-codes'; import { Container } from '..'; export type EndpointInfo = { route: string; path: TPath; operationId: string; operation: TOperation; verb: string; }; export type DocumentorContext = { endpoint: Endpoint; mountpoint: MountPoint; info: InfoBlock; opts: ApiDocsOpts; container: Container; }; export type CustomDocumentor = { [Method in keyof Controller]?: (context: DocumentorContext) => EndpointInfo; } & { kind: 'custom'; }; export interface GenricDocumentor { kind: 'generic'; getInfo(context: DocumentorContext): EndpointInfo; } export type Documentor = CustomDocumentor | GenricDocumentor; export type RequestDefinition = Record; export type ResponseDefinition = Record; export type Responses = Partial>; export type ErrorStatusCodes = StatusCodes[]; export type ContractInfo = { description?: string; summary?: string; }; export type ContractDefinition = { info?: () => ContractInfo; params?: () => Record; query?: () => Constructor; request?: () => RequestDefinition; response?: () => Responses; errors?: () => Responses; errorCodes?: () => ErrorStatusCodes; querySchema?: () => any; }; export type ApiDocsOpts = { tag?: { name: string; description: string; }; generator?: () => Constructor; }; export declare function ApiDocs(opts: ApiDocsOpts): ClassDecorator; /** * @internal */ export declare function getApiDocs(target: Function): ApiDocsOpts; export declare function Contract(contract: ContractDefinition): MethodDecorator; export declare function ParamSchema(params: Record): MethodDecorator; /** * @internal */ export declare function getParamSchema(target: Function, property: string | symbol): any; export declare function QuerySchema(params: () => Record): MethodDecorator; /** * @internal */ export declare function getQuerySchema(target: Function, property: string | symbol): any; export declare function getSimpleQuerySchema(target: Function, property: string | symbol): any; export declare function RequestSchema(schema: any): MethodDecorator; /** * @internal */ export declare function getRequestSchema(target: Function, property: string | symbol): any; export declare function ResponseSchema(schema: any): MethodDecorator; /** * @internal */ export declare function getResponseSchema(target: Function, property: string | symbol): any; export declare function ErrorSchema(schema: any): MethodDecorator; /** * @internal */ export declare function getErrorSchema(target: Function, property: string | symbol): any; export declare function ErrorStatusCodes(codes: ErrorStatusCodes): MethodDecorator; /** * @internal */ export declare function getErrorCodes(target: Function, property: string | symbol): any; export declare function Info(info: ContractInfo): MethodDecorator; /** * @internal */ export declare function getInfo(target: Function, property: string | symbol): any;