【发布时间】:2017-02-06 11:51:33
【问题描述】:
我正在编写以下 Json Schema:
{
"$schema": "http://json-schema.org/schema#",
"title": "Layout",
"description": "The layout created by the user",
"type": "object",
"definitions": {
"stdAttribute": {
"type": "object",
"properties": {
"attributeValue": {
"type": "object"
},
"attributeName": {
"type": "string"
}
}
},
"stdItem": {
"type": "object",
"required" : ["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"
}
}
}
}
}
}
当我设置以下数据时:
{
"stdItem": {
"stdType": "CONTAINER",
"stdAttributes": [],
"children": []
}
}
验证器说没有错误,但是在架构中我使用了一个 minItems 和一个对 "StdAttributes" 中的 "StdAttribute" 架构的引用。。 p>
我尝试在基本架构中定义此属性,但验证器说同样的话。
我应该如何验证“StdAttributes”中项目的类型和数量?
我正在使用 Java 验证器。
【问题讨论】:
标签: json jsonschema json-schema-validator