@@ -163,6 +163,7 @@ function queryHandler (queryParameters, options) {
163
163
queryParameters . forEach ( qp => {
164
164
parameters [ qp . name . value ( ) . toLowerCase ( ) ] = qp
165
165
} )
166
+ const schemaProm = nodeShapeFromParams ( queryParameters )
166
167
167
168
return async function ospreyQuery ( req , res , next ) {
168
169
const reqUrl = parseurl ( req )
@@ -183,8 +184,8 @@ function queryHandler (queryParameters, options) {
183
184
req . query = extend ( req . query , query )
184
185
}
185
186
186
- const schema = await nodeShapeFromParams ( queryParameters )
187
- const report = await validateWithExtras ( schema , JSON . stringify ( query ) )
187
+ const report = await validateWithExtras (
188
+ await schemaProm , JSON . stringify ( query ) )
188
189
if ( ! report . conforms ) {
189
190
return next ( createValidationError (
190
191
formatRamlValidationReport ( report , 'query' ) ) )
@@ -217,9 +218,9 @@ function headerHandler (headers = [], options) {
217
218
params [ header . name . value ( ) ] = header
218
219
} )
219
220
221
+ const defaultParams = makeDefaultRequestHeadersParams ( )
220
222
return async function ospreyMethodHeader ( req , res , next ) {
221
- const defaultParams = await makeDefaultRequestHeadersParams ( )
222
- params = extend ( defaultParams , params )
223
+ params = extend ( await defaultParams , params )
223
224
params = lowercaseKeys ( params )
224
225
const sanitize = ramlSanitize ( Object . values ( params ) )
225
226
req . headers = lowercaseKeys ( req . headers )
0 commit comments