swagger - 在数组 swagger 模式中定义不同对象结构的正确方法是什么?
问题描述
我希望这是一个合法的问题,我到处搜索示例或任何有关如何执行此操作的信息来源。我也试过这个https://github.com/fotinakis/swagger-blocks/issues/17。但同样的结果。
我想生成的最终结果如下:
{
"name": "Awesome Promotion",
"description": "30% off",
"qualifiers": [
{
"id": 12,
"type": "Rental"
},
{
"id": 13,
"type": "Qualifier",
"user_id": 23
},
{
"id": 14,
"type": "First",
"location_id": 32
}
]
我将模型写成这样:
swagger_schema :PromotionResponse do
property :name, type: :string, example: 'Awesome Promotion'
property :description, type: :string, example: '30% off'
property :qualifiers do
key :type, :array
items do
property :id, type: :integer, example: 2
property :type, type: :string, exmple: 'Location'
end
end
end
现在由 swagger 生成的内容:
{
"name": "Awesome Promotion",
"description": "30% off",
"qualifiers": [
{
"id": 2,
"type": "Location"
}
]
}
在数组模式中定义不同对象结构的正确方法是什么?
解决方案
推荐阅读
- sql - 如何在不写 where 条件的情况下在查询中使用时间函数?
- android - 从 xml 调用 View Model 方法不会在 android 中调用问题
- android - 使用 Work Manager 更新网络请求的逻辑
- c++ - (Rcpp)armadillos abs() 函数在 std::abs 工作时与 c++ double 一起使用时输出错误值
- python - 在 Python 中遍历另一个脚本的不同类
- c# - 如何在当前方法中使用数据库事务?
- google-apps-script - 谷歌工作表按钮在移动设备上不起作用
- r - R中的命令filter()有问题吗?match.arg(method) 中的错误:“arg”必须为 NULL 或字符向量
- sql - 插入查询 - 将数据类型 nvarchar 转换为 (null) 时出错
- node.js - Shell 文件忙