Skip to content

Commit

Permalink
Merge pull request #75 from medolino/fix-#74
Browse files Browse the repository at this point in the history
Fix #74
  • Loading branch information
cdimascio authored Oct 18, 2019
2 parents 522c057 + e70d3f6 commit 3d91e6a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/middlewares/openapi.multipart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import * as multer from 'multer';
export function multipart(openApiContext: OpenApiContext, multerOpts: {} = {}) {
const mult = multer(multerOpts);
return (req, res, next) => {
if (isMultipart(req)) {
if (!isValidContentType(req)) {
throw validationError(415, req.path, 'unsupported media type');
}
if (isMultipart(req) && isValidContentType(req)) {
mult.any()(req, res, err => {
if (err) {
next(error(req, err));
Expand Down
2 changes: 1 addition & 1 deletion test/multipart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe(packageJson.name, () => {
.with.length(1);
expect(r.body.errors[0])
.has.property('message')
.equal('unsupported media type');
.equal('unsupported media type application/json');
}));
});
});

0 comments on commit 3d91e6a

Please sign in to comment.