输入
{
"createResponse": {
"backResponse": {
"status": {
"code": "000",
"message": "success"
}
}
}
}
或
{
"updateResponse": {
"backResponse": {
"status": {
"code": "000",
"message": "success"
}
}
}
}
这是我的json架构:
{
"properties": {
"backResponse": {
"type": "object",
"additionalProperties": false,
"properties": {
"status": {
"type": "object",
"required": false,
"properties": {
"code": {
"type": "string",
"required": false
},
"message": {
"type": "string",
"required": false
}
}
}
}
}
},
"anyOf": [{
"additionalProperties": false,
"properties": {
"createResponse": {
"type": "object",
"properties": {
"$ref": "#/properties/backResponse"
}
}
}
}, {
"additionalProperties": false,
"properties": {
"updateResponse": {
"type": "object",
"properties": {
"$ref": "#/properties/backResponse"
}
}
}
}]
}
在datapower中将此错误视为属性' $ ref'的意外值。预期价值类型:'对象'。得到了:'"#/ properties / backResponse" ...'
我做错了什么
答案 0 :(得分:1)
如果你只想强制执行updateResponse的类型为backResponse,你可以像这样引用它:
"createResponse" : {"$ref" : "#/properties/backResponse"}
JSON Reference resolution is added to DataPower firmware from version 6.0.1。您还应该检查您的版本。
最后我必须警告你正在使用Json-Schema Draft3。在Draft4中需要一个数组。