apiaryio / api-blueprint

API Blueprint
https://apiblueprint.org
MIT License
8.64k stars 2.14k forks source link

What's the status on multipart/form-data requests support? #376

Closed vnenkpet closed 5 years ago

vnenkpet commented 7 years ago

We just run into na issue where when we have request such as

+ Request

    + Headers

            Content-Type: multipart/form-data; boundary=BOUNDARY

    + Body

            --BOUNDARY
            Content-Disposition: form-data; name="name"

            John Doe
            --BOUNDARY
            Content-Disposition: form-data; name="email"

            john.doe@email.com
            --BOUNDARY--

we are not able to run succesfully it in the apiary console on app.apiary.io against our own endpoint because we are getting

{
  "message": "Unexpected end of multipart data"
}

back as a response from the server (running Node.js using async-busboy package to handle multipart requests), however we know this end-point works correctly when we use it vith Postman or HTML form handled with JQuery or curl.

Is this a bug, or are these requests simply not supported, or is there something wrong with the .apib code snippet above?

I know there are issues related to multipart handling but I can't find a solid info about the current status of multipart/form-data support in Blueprint.

zdne commented 7 years ago

@vnenkpet I think you have the inconsistent boundary there: BOUNDARY vs --BOUNDARY vs --BOUNDARY-- .

See http://stackoverflow.com/questions/24207495/how-do-i-document-a-multipart-request-with-apiary

FranklinYu commented 7 years ago

@zdne So the format in the body section is not what actually gets sent? In HTML specification the last boundary should be --BOUNDARY--.

kylef commented 5 years ago

The request body as-is is what should be sent, the parser should not modify the contents.

I would take a guess the problem might be with the line endings themselves, as the markdown document will only contain a new line. Whereas multipart form implementations may expect a carridge return and a new line. I believe some tooling such as Dredd will automatically convert these newlines in multipart responses to contain a carriage return.

kylef commented 5 years ago

This problem is tracked via https://github.com/apiaryio/api-blueprint/issues/401