// TypeScript Version: 3.2 /** * Initialize the input validation middleware by * providing it with the swagger file path and * configuration options. This function should be called * before using `validate` middleware. */ declare function init(schemaPath: string, options?: ajvValidatorOptions): void; declare function init(jsonSchema: Record, options?: ajvValidatorOptions): void; export { init }; export { initAsync }; export { validate }; export { getNewMiddleware }; /** * Initialize the input validation middleware by * providing it with the swagger file path and * configuration options. This function should be called * and awaited before using `validate` middleware. * This init variant support loading of external references. */ declare function initAsync(schemaPath: string, options?: ajvValidatorOptions): Promise; declare function initAsync(jsonSchema: Record, options?: ajvValidatorOptions): Promise; /** * Middleware that validates the request against the swagger * file, according to the request method and route */ declare function validate(ctx: Record, next: Function): void; // koa declare function validate(req: Record, res: Record, next: Function): void; // express declare function validate(options: FastifyPluginOptions): any; // fastify export class InputValidationError extends Error { errors: Array; constructor(errors: Array, options?: inputValidationOptions) } export interface ErrorDetails { dataPath: string; keyword: string; message: string; params: Record; schemaPath: string; } export type frameworks = 'koa' | 'express' | 'fastify'; export interface format { name: string; pattern: RegExp | string; } export interface FastifyPluginOptions { skiplist?: Array; } export interface ajvValidatorOptions { ajvConfigBody?: Record; ajvConfigParams?: Record; beautifyErrors?: boolean; contentTypeValidation?: boolean; errorFormatter?: (errors: Array, options: ajvValidatorOptions) => Error; expectFormFieldsInBody?: boolean; firstError?: boolean; framework?: frameworks; formats?: Array; keywords?: any; makeOptionalAttributesNullable?: boolean; } export interface inputValidationOptions { beautifyErrors?: boolean; firstError?: boolean; } declare class MiddlewareClass { InputValidationError: InputValidationError; init(schemaPath: string, options?: ajvValidatorOptions): void; // eslint-disable-next-line no-dupe-class-members init(jsonSchema: Record, options?: ajvValidatorOptions): void; initAsync(schemaPath: string, options?: ajvValidatorOptions): Promise; // eslint-disable-next-line no-dupe-class-members initAsync(jsonSchema: Record, options?: ajvValidatorOptions): Promise; validate(ctx: Record, next: Function): void; // koa // eslint-disable-next-line no-dupe-class-members validate(req: Record, res: Record, next: Function): void; // express // eslint-disable-next-line no-dupe-class-members validate(options: FastifyPluginOptions): any; // fastify } declare function getNewMiddleware(schemaPath: string, options?: ajvValidatorOptions): MiddlewareClass;