How do I document a multipart request with apiary?
How do I document a multipart request with apiary?
I want to document a multipart request like the following:
Content-Length: 477
Content-Type: multipart/form-data; boundary=---BOUNDARY
-----BOUNDARY
Content-Disposition: form-data; name="image[file]"; filename="image.jpg"
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0a
HBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIy
MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAABAAEDASIA
AhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFAEB
AAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AL+AD//Z
-----BOUNDARY--
A curl
to reproduce this same request would be something like:
curl
curl -F "image[file]=@file.jpg" http://localhost/images
1 Answer
1
To create a multipart request with API Blueprint simply create a request with multipart/form-data; boundary=---BOUNDARY
Content-type and use the respective boundary markers in the body asset like so:
multipart/form-data; boundary=---BOUNDARY
# POST /images
+ Request (multipart/form-data; boundary=---BOUNDARY)
-----BOUNDARY
Content-Disposition: form-data; name="image[file]"; filename="image.jpg"
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0a
HBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIy
MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAABAAEDASIA
AhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFAEB
AAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AL+AD//Z
-----BOUNDARY
+ Response 201 (text/plain)
Ok.
See also this link on Apiary directly jsapi.apiary.io/apis/sparkdriveapi/reference/files/upload/… But what I see, is that Apiary is not doing very well in that kind of more complex scenarios. The blueprint becomes again just a html style documentation and not a "living documentation" what we want to achieve. Maybe doing all in Postman is better. I still have to investigate how in Postman I can describe nicely all the API parts.
– Dafka
2 days ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
This doesn't seem to be supported yet. There's an issue here discussing how best to do it github.com/apiaryio/api-blueprint/issues/100
– thomax
Sep 13 '16 at 13:41