Ruby 以数组作为根对象的Grape路由
我正在为这样的葡萄路线定义参数Ruby 以数组作为根对象的Grape路由,ruby,grape,grape-api,Ruby,Grape,Grape Api,我正在为这样的葡萄路线定义参数 params do requires :array, type: Array do requires :foo, type: String requires :bar, type: String end end 此端点的数据将是{“array”:[{“foo”:“123”,“bar”:“456”} 如何摆脱附加的“数组”?数据应该如下所示[{“foo”:“123”,“bar”:“45
params do
requires :array, type: Array do
requires :foo, type: String
requires :bar, type: String
end
end
此端点的数据将是{“array”:[{“foo”:“123”,“bar”:“456”}
如何摆脱附加的“数组”
?数据应该如下所示[{“foo”:“123”,“bar”:“456”}]
我无法在
参数上定义类型数组
您可以使用组来完成此操作,有关详细信息,请访问
e、 g:
情妇
组:数组,类型:数组do
需要:foo,类型:String
需要:条,类型:字符串
...
结束
结束我认为大多数DSL之所以跳过这一点,是因为存在漏洞(如本文所述:)好吧,这是有道理的!谢谢