0
我在我的数据库扬鞭和JSON补丁
{
partnerName: '24 Fitness',
supportedProducts: [
'FitBit',
'Protein Powder'
]
},
以下对象结构,其中所述键值supportedProducts可以从客户端进行修改。
我正在构建一个PATCH API方法,使用swagger文档来支持上述功能。但我不确定修补程序对象的定义,因为文档没有提供构建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"}
}
}
}
}
您的服务器期望什么请求的URL和主体? – Helen
@Helen请求URL是/ data/{partnerName},body应该指定partnerName和supportedProducts作为值。但在我的情况下,当我尝试配置上述json时,失败了,我可以运行服务器并发出请求之前的方式 – user8222014
这是您的整个JSON定义还是仅提取它? (因为这个代码本身不是一个有效的JSON。) – Helen