【发布时间】:2016-04-24 01:41:37
【问题描述】:
我正在尝试在 JSON 模式中定义一个数组元素。它们的数组包含来自架构的 definitions 部分中已定义的类型的项目。
我试过了:
"properties": {
"userId": {"$ref": "#/definitions/userId"},
"beacons": {
"type": "array",
"items": { "$ref": "#/definitions/beaconSchema" }
}
}
userId 部分用#/definitions/userId 解析。但是,列表项会忽略 #/definitions/beaconSchema 并允许其中包含任何旧垃圾。
如何使用 JSON 架构 definition 解析 JSON 数组中的所有项目?
【问题讨论】:
-
您发布的架构片段是正确的。我建议您在
$ref路径和definitions属性名称中查找拼写错误。如果您在那里没有发现问题,请尝试发布更多架构。 -
@Jason 你是对的,
additionalProperties定义中缺少键。请写下这个作为答案,我会接受。 -
会的。很高兴你明白了。
标签: arrays definition jsonschema