我的数据库中具有以下对象结构
{
partnerName: '24 Fitness',
supportedProducts: [
'FitBit',
'Protein Powder'
]
},
Run Code Online (Sandbox Code Playgroud)
其中可以从客户端修改键值supportedProducts。
我正在使用swagger文档构造PATCH API方法以支持上述功能。但是我不确定补丁对象的定义,因为文档没有提供构造PATCH的详细示例。
我所拥有的当前定义最终在执行时出错,如下所示
"patch":{
"description":"Update supported products for a partner",
"operationId":"Update supported products",
"parameters":[
{
"name": "partnerName",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "supportedProducts",
"in": "body",
"required": true,
"schema":{
"$ref":"#/definitions/PatchRequest"
}
}
],
"responses":{
"200":{
"description": "product updated"
},
"404":{
"description": "Not Found"
}
}
"definitions": {
"PatchRequest":{
"type": "object",
"required":[
"partnerName",
"supportedProducts"
],
"properties":{
"partnerName":{"type": "string"},
"supportedProducts":{
"type": "array",
"items":{"type": "string"} …Run Code Online (Sandbox Code Playgroud)