我有這個架構的JSON響應JSON模式爲對象的數組不驗證
{
"title": "Products",
"description": "schema for products",
"type": "array",
"properties": {
"id": {
"description": "id of a product",
"type": "integer"
},
"name": {
"description": "name of the product",
"type": "string"
},
"created_at": {
"description": "record created_at",
"type": "string",
"format": "date-time"
},
"updated_at": {
"description": "record updated_at",
"type": "string",
"format": "date-time"
}
},
"required": ["id", "name"]
}
,我想這個模式與此JSON
[{
"id": 1,
"name": "Cricket Ball"
}, {
"id": 2,
"name": "Soccer Ball"
}, {
"id": 3,
"name": "football ball"
}, {
"id": 4,
"name": "Basketball ball"
}, {
"id": 5,
"name": "Table Tennis ball"
}, {
"id": 6,
"name": "Tennis ball"
}]
匹配這個模式的響應相匹配但它也匹配所需字段是這樣的架構
"required": ["ids", "names"]
我認爲架構已驗證獲得數組並且數組中的對象未經驗證。
它很不清楚您實際上在做什麼。如果您使用的是AMS,請包含控制器和視圖(如果您使用的是jbuilder)或序列化程序。 – max
這與軌道無關。在最近的編輯中刪除了rails標籤 – Officer