Я работаю над такой схемой json:
{
"$schema": "http://json-schema.org/schema#",
"title": "Layout",
"description": "The layout created by the user",
"type": "object",
"definitions": {
"stdAttribute": {
"type": "object",
"required": ["attributeName","attributeValue"],
"properties": {
"attributeValue": {
"type": "string"
},
"attributeName": {
"type": "string"
}
}
},
"stdItem": {
"type": "object",
"required" : ["stdType","stdAttributes"],
"properties": {
"stdType": {
"enum": [
"CONTAINER",
"TEXT",
"TEXTAREA",
"BUTTON",
"LABEL",
"IMAGE",
"MARCIMAGE",
"DATA",
"SELECT",
"TABLE"
]
},
"stdAttributes": {
"type": "array",
"items": {
"$ref": "#/definitions/stdAttribute"
},
"minItems": 1
},
"children": {
"type": "array",
"items": {
"$ref": "#/definitions/stdItem"
}
}
}
}
},
"properties":{
"stdItem":{ "$ref": "#/definitions/stdItem" }
}
}
Я пытаюсь проверить следующий json с помощью приведенной выше схемы:
{
"stdItem": {
"stdType": "CONTAINER",
"stdAttributes": [
{
"attributeName": "ola",
"attributeValue": "teste"
}
],
"children": [
{
"stdItem": {
"stdType": "TEXT",
"stdAttributes": [
{
"attributeName": "ola",
"attributeValue": "teste"
}
],
"children": []
}
}
]
}
}
Я получаю сообщение об ошибке, сообщающее мне, что требуемые атрибуты stdType и stdAttributes отсутствуют для пути stdItem / children / 0. Как видите, атрибуты есть, они не пропущены.
Я попытался изменить порядок атрибутов, но все равно не работает. Я получаю следующую ошибку:
--- НАЧАЛЬНЫЕ СООБЩЕНИЯ --- ошибка: у объекта отсутствуют необходимые свойства (["stdAttributes", "stdType"]) level: "error" schema: {"loadingURI": "#", "pointer": "/ definitions / stdItem "} экземпляр: {" указатель ":" / stdItem / children / 0 "} домен:" проверка "ключевое слово:" требуется "требуется: [" stdAttributes "," stdType "] отсутствует: [" stdAttributes "," stdType " ] --- КОНЕЦ СООБЩЕНИЙ ---
Может ли кто-нибудь указать мне на то, что я делаю неправильно?