apigee-127 / swagger-node-runner

The heart of Swagger-Node
MIT License
102 stars 124 forks source link

Unhandled exception in swagger_params_parser.js #100

Open szilveszterb opened 7 years ago

szilveszterb commented 7 years ago

I'm using swagger-express-mw v0.7.0 with swagger. I have an endpoint consuming content type multipart/form-data and it has a parameter with type file.

If I do a POST to that endpoint with content type multipart/form-data and I deliberately omit the file as a test, then an Exception is thrown from the getValue function in swagger_params_parser.js, line 40:

params[parameter.name] = parameter.getValue(req); // note: we do not check for errors here

In that case next() is never called.

A try - catch around that code would solve the issue. Let me know if this was an acceptable solution.

The error log:

Error: req.files must be provided for 'formData' parameters of type 'file' at Parameter.getValue (/Users/szilveszterb/work/projects/murano/okami_api/node_modules/sway/lib/types/parameter.js:141:15) at /Users/szilveszterb/work/projects/murano/okami_api/node_modules/swagger-node-runner/fittings/swagger_params_parser.js:40:44 at Array.forEach (native) at /Users/szilveszterb/work/projects/murano/okami_api/node_modules/swagger-node-runner/fittings/swagger_params_parser.js:39:46 at finishedParseBody (/Users/szilveszterb/work/projects/murano/okami_api/node_modules/swagger-node-runner/fittings/swagger_params_parser.js:128:12)