apigee-127 / swagger-node-runner

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

Parameter option "required" is ignored when type is file #92

Closed Celadora closed 7 years ago

Celadora commented 7 years ago

It seems like swagger is ignoring the option to not require a parameter when that parameter is a file.

  parameters:
    - name: photo
      in: formData
      description: The uploaded photo
      required: false
      type: file

Error: req.files must be provided for 'formData' parameters of type 'file'

If I remove the parameter everything works fine, and multer can process the file.

Note: the solution of putting multer (or other file parsing middleware) before swagger isn't suitable, however, because not all requests are going to have a file, and the processing of different paths may require different middle ware solutions.

Celadora commented 7 years ago

I'm starting to think this is a problem with bagpipes and not Swagger, sorry for the confusion.

theganyo commented 7 years ago

I don't understand: Where is this error coming from? Is it a Swagger validation error? Or is it a Multer error?

Celadora commented 7 years ago

I think it's a Swagger validation error, Multer doesn't get reached if this error is thrown. Edit: and the error is only thrown if I have that parameter, regardless of whether it is required.

theganyo commented 7 years ago

If it's an issue with Swagger validation, most likely this is something that will need to be addressed in Sway. https://github.com/apigee-127/sway

Celadora commented 7 years ago

I'll try reposting there if I can't find a solution. Thank you!