我一直在查看 RAML 规范,试图找到如何表示可以包含多个值的表单参数(比如说“选择:[choice1,choice2,choice3]”)。规范中有一个“repeat”属性,它应该允许您在“post”定义(或任何其他接受请求属性的 http 方法)中重用参数名称,但是 RAML api-designer(截至 06/ 08/2015) 无法识别“重复”并将其标记为错误。有没有人找到解决这个问题的方法?
例子
预期资源
{choices : ["Choice 1 rocks", "Choice 2 rocks"]}
这失败了
post:
description: create a resource
body:
application/x-www-form-urlencoded:
formParameters:
choices:
displayName: Choice 1
description: first choice
type: string
required: true
repeat: true
example: Choice 1 rocks!
choices:
displayName: Choice 2
description: second choice
type: string
required: true
repeat: true
example: Choice 2 rocks!
如果您选择拆分参数,这可以规避问题
{
choice1 : "Choice 1 rocks!",
choice2 : "Choice 2 rocks!"
}
post:
description: create a resource
body:
application/x-www-form-urlencoded:
formParameters:
choice1:
displayName: Choice 1
description: first choice
type: string
required: true
example: Choice 1 rocks!
choice2:
displayName: Choice 2
description: second choice
type: string
required: true
example: Choice 2 rocks!