【发布时间】:2017-08-08 17:58:10
【问题描述】:
在core/validation meta-schema、items和type属性中定义如下:
项目
"items": {
"anyOf": [
{ "$ref": "#" },
{
"type": "array",
"minItems": 1,
"items": { "$ref": "#" }
}
],
"default": {}
},
类型
"type": {
"anyOf": [
{ "$ref": "#/definitions/simpleTypes" },
{
"type": "array",
"items": { "$ref": "#/definitions/simpleTypes" },
"minItems": 1,
"uniqueItems": true
}
]
},
据我了解:
-
items可以是一个模式或至少一个模式的数组 -
type可以是simpleType或至少一个simpleType的数组
除了写作的实用性和舒适性之外,我是否认为这些定义是等价的?
项目
"items": {
"type": "array",
"items": { "$ref": "#" }
"default": [{}]
},
类型
"type": {
"type": "array",
"items": { "$ref": "#/definitions/simpleTypes" },
"uniqueItems": true
},
换句话说,以下两种模式的解释是否存在差异:
架构 #1
{
"type": "array",
"items": {
"type": "string"
}
}
模式 #2
{
"type": ["array"],
"items": [
{
"type": "string"
}
]
}
【问题讨论】:
标签: jsonschema