mulesoftramlmule4

RAML for multiple files as output


I am new to RAML 1.0 I want to mention multiple csv files as response. My API will be creating multiple csv file for different entities. I want to mention this multiple file in response in RAML. Can you suggest what should be response for multiple files in RAML.


Solution

  • The body in HTTP requests and reponses is formed of one payload. You should use one zip, or a tar, tar.gz, etc, file to compress the files inside one file, or use a multi-part response to convey that each file is an attachement.

    Example of a zip response:

    #%RAML 1.0
    title: test-attachment
    
    /resource:
      post:
        responses:
          200:
            body:
              application/zip:
    

    Example of multi-part response:

    #%RAML 1.0
    title: test-attachment
    
    /resource:
      post:
        responses:
          200:
            body:
              multipart/form-data:
                properties:
                    file1:
                        type: file
                        fileTypes: ['application/csv']
                    file2:
                        type: file
                        fileTypes: ['application/csv']