How do I document a multipart request with apiary?

前端 未结 1 1029
谎友^
谎友^ 2021-02-01 03:57

I want to document a multipart request like the following:

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

-----BOUNDARY
Content-Dis         


        
相关标签:
1条回答
  • 2021-02-01 04:49

    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:

    # 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.
    
    0 讨论(0)
提交回复
热议问题