PayU / openapi-validator-middleware

Input validation using Swagger (Open API) and ajv
Apache License 2.0
144 stars 50 forks source link

Allow single file upload #150

Closed setaman closed 3 years ago

setaman commented 3 years ago

Both req.files and req.file must be considered for handling multipart/form-data validation. This is necessary to allow uploading of a single file with multer. Otherwise something like upload.single("image") will not work.

This is a small and important fix. However, it does not improve the validation itself. Without this fix, uploading a single file will cause requestOptions.files to be undefined. But the validation passes anyway. The same when no file is uploaded at all!