@@ -68,13 +68,13 @@ export class RequestValidator {
6868 // cache middleware by combining method, path, and contentType
6969 const contentType = ContentType . from ( req ) ;
7070 const contentTypeKey = contentType . equivalents ( ) [ 0 ] ?? 'not_provided' ;
71- const key = `${ req . method } -${ route } -${ contentTypeKey } ` . toLocaleLowerCase ( ) ;
71+ const key = `${ req . method || req . httpMethod } -${ route } -${ contentTypeKey } ` . toLocaleLowerCase ( ) ;
7272
7373 if ( ! this . middlewareCache [ key ] ) {
7474 if ( this . validationModule [ key ] ) {
7575 this . middlewareCache [ key ] = this . buildMiddlewareFromModule ( key ) ;
7676 } else {
77- this . middlewareCache [ key ] = this . buildMiddleware ( key , route , req . method , contentType ) ;
77+ this . middlewareCache [ key ] = this . buildMiddleware ( key , route , req . method || req . httpMethod , contentType ) ;
7878 }
7979 }
8080
@@ -147,18 +147,11 @@ export class RequestValidator {
147147
148148 private buildMiddlewareFromModule ( validationId : string ) : OpenApiRequestHandler {
149149 return ( req : OpenApiRequest ) : void => {
150- const cookies = req . cookies
151- ? {
152- ...req . cookies ,
153- ...req . signedCookies
154- }
155- : undefined ;
156-
157150 const data = {
158- query : req . query ?? { } ,
159- headers : req . headers || { } ,
160- path : req . path || { } ,
161- cookies,
151+ query : req . query ?? req . queryStringParameters ?? { } ,
152+ headers : req . headers ?? { } ,
153+ path : req . path ?? req . pathParameters ?? { } ,
154+ cookies : req . cookies ?? { } ,
162155 body : req . body
163156 } ;
164157
@@ -208,18 +201,11 @@ export class RequestValidator {
208201 const validator = this . ajv . compile ( schemaGeneral ) ;
209202
210203 return ( req : OpenApiRequest ) : void => {
211- const cookies = req . cookies
212- ? {
213- ...req . cookies ,
214- ...req . signedCookies
215- }
216- : undefined ;
217-
218204 const data = {
219- query : req . query ?? { } ,
220- headers : req . headers || { } ,
221- path : req . path || { } ,
222- cookies,
205+ query : req . query ?? req . queryStringParameters ?? { } ,
206+ headers : req . headers ?? { } ,
207+ path : req . path ?? req . pathParameters ?? { } ,
208+ cookies : req . cookies ?? { } ,
223209 body : req . body
224210 } ;
225211
0 commit comments