koas-core
Version:
> [Koa][] + [OpenAPI Specification][] = Koas
31 lines (30 loc) • 930 B
TypeScript
import { Validator, ValidatorResult } from 'jsonschema';
import { OpenAPIV3 } from 'openapi-types';
interface SchemaValidationErrorOptions {
/**
* The HTTP status code for the validation error.
*/
status?: number;
/**
* The JSON schema validator result.
*/
result: ValidatorResult;
}
/**
* An error that’s thrown if JSON schema validation fails.
*/
export declare class SchemaValidationError extends Error {
status: number;
result: ValidatorResult;
/**
* @param message - The error message to throw.
* @param options - The error options.
*/
constructor(message: string, { result, status }: SchemaValidationErrorOptions);
}
/**
* @param document - THe OpenAPI document to create a JSON schema validator for.
* @returns A configured JSON schema validator.
*/
export declare function createValidator({ components }: OpenAPIV3.Document): Validator;
export {};