Mule esb: проверка элементов массива в файле .raml

У меня есть следующее определение схемы json в моем файле .raml

- 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"
    }
]
}

Если схема не находится внутри массива, проверка работает правильно. Но находясь внутри массива, он не проверяет ни один элемент, имеющий обязательный атрибут.

Нужна ли мне особая конфигурация?

Спасибо.


person Enrique Cuchetti    schedule 17.03.2015    source источник
comment
Покажите схему, когда она у вас есть внутри массива.   -  person David Dossot    schedule 17.03.2015


Ответы (2)


после некоторой борьбы я смог заставить его работать, используя это:

 - 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"

person Enrique Cuchetti    schedule 21.03.2015

Вы не ответили на мой вопрос, поэтому я могу только предположить, что вы неправильно включили определение внутреннего объекта. Видя ваш собственный ответ и ссылку на борьбу, я тоже хотел бы предложить ответ.

Вот автономное и бесплатное представление вашей схемы:

{
    "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
                    }
                }
            }
        }
    }
}
person David Dossot    schedule 21.03.2015