请求部件的RAML规范

时间:2017-09-15 16:39:52

标签: rest api curl raml

我尝试用两部分为请求定义raml规范。以下是卷曲示例:

results = h1.map do |base|
  sum = 0

  h2[base[:item]].take_while do |item|
    sum += item[:value] if sum < base[:value]
  end.map do |item|
    [base[:id], item[:id]]
  end
end

# => [[[1, 1], [1, 2]], [[1, 4], [1, 5]]]

我想要类似的东西:

puts results.flatten(1).inspect
# => [[1, 1], [1, 2], [1, 4], [1, 5]]

但它不是有效的RAML。我如何在RAML中定义请求部分?

1 个答案:

答案 0 :(得分:0)

您只需将所有属性放在multipart / form-data下。试试这个:

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

另一个选项可能更接近您提供的代码:

  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