RAML specification for request parts

616 Views Asked by At

I try to define raml specification for request with two parts. Below is curl example:

curl --header "Authorization: ***" -F "[email protected]" -F metadata='{"file_size":879394}' http://***/v1/media_photos

I would like something like like:

#%RAML 1.0
title: test

/media_photos:
  post:
    description: Send Receipt with additional information
    headers:
      Authorization:
        description: Authorization header. Will be implemented(changed)     further.
        required: true
        example: K7ny27JTpKVsTgdyLdDfmQQWVLERj2zAK5BslRsqyw
    body:
      metadata: // not valid
        application/json:
          properties:
            file_size:
              type: integer
              example: 879394
              required: true
      photo: //not valid
        multipart/form-data:
          properties:
            file:
              description: Upload file
              type: file
              required: true

But it is not a valid RAML. How I can define request parts in RAML?

1

There are 1 best solutions below

0
On

You simply need to put all properties under the multipart/form-data. Try this:

post:
  body:
    multipart/form-data:
      properties:
        file:
          description: The file to be uploaded
          required: true
          type: file
        file_size:
          type: integer
          example: 879394
          required: true

Another option, which may be closer to the code you provided is this:

  body:
    multipart/form-data:
      properties:
        metadata:
          properties:
            file_size:
              type: integer
              example: 879394
              required: true
        photo:
          properties:
            file:
              description: Upload file
              type: file
              required: true