diff --git a/src/openapi.validator.ts b/src/openapi.validator.ts index ac651894..dd12fed2 100644 --- a/src/openapi.validator.ts +++ b/src/openapi.validator.ts @@ -155,19 +155,6 @@ export class OpenApiValidator { .catch(next); }); - if (this.options.fileUploader) { - // multipart middleware - let fumw; - middlewares.push(function multipartMiddleware(req, res, next) { - return pContext - .then(({ context: { apiDoc } }) => { - fumw = fumw || self.multipartMiddleware(apiDoc); - return fumw(req, res, next); - }) - .catch(next); - }); - } - // security middlware let scmw; middlewares.push(function securityMiddleware(req, res, next) { @@ -184,6 +171,19 @@ export class OpenApiValidator { .catch(next); }); + if (this.options.fileUploader) { + // multipart middleware + let fumw; + middlewares.push(function multipartMiddleware(req, res, next) { + return pContext + .then(({ context: { apiDoc } }) => { + fumw = fumw || self.multipartMiddleware(apiDoc); + return fumw(req, res, next); + }) + .catch(next); + }); + } + // request middlweare if (this.options.validateRequests) { let reqmw;