serverless-plugin-swagger-api
Version:
Define your API Endpoints in OpenAPI format (swagger) and create APIGW integration automatically
42 lines (41 loc) • 1.22 kB
TypeScript
export declare type HTTPMethod = 'get' | 'post' | 'put' | 'delete' | 'patch';
export interface HandlerEvent {
http: BaseEventConfig & {
path: string;
method: HTTPMethod;
};
}
export interface BaseEventConfig {
cors?: boolean;
private?: boolean;
authorizer?: {
name?: string;
arn?: string;
resultTtlInSeconds?: number;
identitySource?: string;
identityValidationExpression?: string | RegExp;
type?: string;
};
}
export declare type SecurityDefinition = {
'x-attr-arn'?: string;
'x-attr-name'?: string;
};
export interface SwaggerFile {
paths: Record<string, Record<HTTPMethod, SwaggerPath>>;
securityDefinitions: Record<string, SecurityDefinition>;
}
export interface SwaggerPath {
security?: Record<string, any>[];
produces: string[];
responses: Record<number, {
description: string;
schema: {
$ref: string;
};
}>;
'x-attr-serverless': BaseEventConfig & {
functionName: string;
};
}
export declare const mapSwaggerFileToFunctionEvents: (swagger: SwaggerFile, log?: (message?: any, ...optionalParams: any[]) => void) => Record<string, HandlerEvent[]>;