Mule esb:验证.raml文件中的数组项
我的.raml文件中有以下json模式定义Mule esb:验证.raml文件中的数组项,mule,esb,mule-studio,raml,Mule,Esb,Mule Studio,Raml,我的.raml文件中有以下json模式定义 - request: | { "type": "object", "$schema": "http://json-schema.org/draft-03/schema", "id": "http://jsonschema.net", "required": true, "properties": { "personProperty": { "type": "array", "items":
- request: |
{
"type": "object",
"$schema": "http://json-schema.org/draft-03/schema",
"id": "http://jsonschema.net",
"required": true,
"properties": {
"personProperty": {
"type": "array",
"items": {
"$ref": "property"
}
}
}
}
- property: |
{ "$schema": "http://json-schema.org/draft-03/schema",
"type": "object",
"description": "A single person property",
"properties": {
"fieldId": { "type": "integer", "required": true},
"systemId": { "type": "integer", "required": false},
"value": { "type": "string" , "required": true },
"created": { "type": "string" , "required": false }
}
}
我需要mule ESB在阵列中缺少一个必需字段时拒绝输入
例如,这应该被400-错误请求拒绝:
{
"personProperty": [
{
"fieldId": "1",
"systemId": 1,
"created": "2015-02-23 21:19:00.907"
}
]
}
如果架构不在数组中,则验证工作正常。
但在数组内部时,它不会验证任何具有必需属性的单个项
我需要特殊配置吗
谢谢。经过一段时间的努力,我终于能够使用以下工具使其正常工作:
- request: |
{
"type": "object",
"$schema": "http://json-schema.org/draft-03/schema",
"id": "http://jsonschema.net",
"definitions": {
"person-property": {
"type": "object",
"properties": {
"fieldId": {
"type": "integer",
"required": true
},
"systemId": {
"type": "integer",
"required": false
},
"value": {
"type": "string",
"required": true
},
"created": {
"type": "string",
"required": false
}
}
}
},
"properties": {
"personProperty": {
"type": "array",
"items": {
"$ref": "#/definitions/person-property"
}
}
}
}
我使用了一个内部定义,然后使用“$ref”将其命名为“#/definitions/person property”您没有回答我的问题,因此我只能假设您错误地包含了内部对象定义。看到你自己的答案和挣扎的参考,我也想提出一个答案 以下是您的模式的独立且无引用的表示:
{
"type": "object",
"$schema": "http://json-schema.org/draft-03/schema",
"properties": {
"personProperty": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fieldId": {
"type": "integer",
"required": true
},
"systemId": {
"type": "integer",
"required": false
},
"value": {
"type": "string",
"required": true
},
"created": {
"type": "string",
"required": false
}
}
}
}
}
}
当架构位于数组中时显示它。