apiaryio / api-elements.js

Library for consuming API Elements in JavaScript
https://apielements.org/
MIT License
76 stars 18 forks source link

Support "file" in request/response #267

Open honzajavorek opened 7 years ago

honzajavorek commented 7 years ago

I don't think Swagger adapter correctly supports {"type":"file"} in the request or response. It is a Swagger extension to the spec. Linking relevant docs (also mentioned in the Data Types section). Since this is something specific to a certain format, I think Dredd shouldn't be the one dealing with it. The Swagger adapter should take care of the specifics and pass on something which looks like raw HTTP request-response pair and which Dredd already understands.

Real world example of usage in response can be seen in https://github.com/apiaryio/dredd/issues/883:

...
        responses: 
          200: 
            description: "CVS data"
            schema: 
              type: "file"
...
honzajavorek commented 5 years ago

Currently the file seems to be supported to some extent, but following doesn't work for an HTTP request:

consumes:
  - multipart/form-data; boundary=CUSTOM-BOUNDARY

As it produces an error:

Validation failed. /paths/data/post has a file parameter,
so it must consume multipart/form-data or application/x-www-form-urlencoded
on line 1