raml-spec icon indicating copy to clipboard operation
raml-spec copied to clipboard

define application/json and type file to multipart request

Open dinegri opened this issue 6 years ago • 3 comments

Hi,

I tried to modelling a multipart request using a part as application/json and another part as a file without success.

I am wondering if raml allows you to describe a multipart request like in OpenAPI 3 (https://swagger.io/docs/specification/describing-request-body/multipart-requests/)

Reading Multipart RFC, it allow you to define Content-Type for the parts, so I guess that would be possible using raml

Thanks

dinegri avatar Apr 10 '19 00:04 dinegri

Have you seen this blog post about modeling multipart requests? Does it address your question and if not, can you share an example (even an invalid one) of what you're trying to achieve?

jstoiko avatar Jun 03 '19 21:06 jstoiko

Yes, I have seen. Well I understood that raml 1.0 does not support at least yet something like that openapi/multipart

dinegri avatar Jun 06 '19 12:06 dinegri

Another option is to use a union type to define both the fileType and its underlying JSON structure.

E.g.

#%RAML 1.0
title: My API

types:
  MyFile: 
    type: file
    fileTypes: ['application/json']
  MyFileContent:
    properties:
      foo: integer
      bar: 

/resource:
  post:
    body:
      multipart/form-data:
        properties:
          my_file:
            type: MyFile | MyFileContent

jstoiko avatar Sep 26 '19 20:09 jstoiko