我的API看起来像这样。
products
对象包含产品ID(键)及其在篮子中的数量(值)。
{
"id": "0a4d44aa-2ace-11e7-93ae-92361f002671",
"products": {
4 => 3, // product with ID 4 is 3x in basket
10 => 1, // product with ID 10 is 1x in basket
...
},
// some other values...
}
a)如何用MSON描述这个API?
b)这个架构是否正确?
{
"type": "object",
"properties": {
"id": {
"type": "string",
},
"products": {
"type": "object",
"properties": {
"productId": {
"type": "int",
}
}
},
// some other values
}
}