【发布时间】:2017-08-21 20:00:23
【问题描述】:
我有这个 json:
{
"categories": [
{
"id": 1,
"name": "cat1",
"topics": [
{
"$ref": "#/topics/1"
}
]
}
],
"topics": [
{
"id": 1,
"name": "top1"
}
]
}
我已经编写了下一个模式来验证它:
{
"definitions": {
"category": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"topics": {
"type": "array"
"items": { "$ref": "#/definitions/topic" }
}
}
},
"topic": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
}
}
}
},
"type": "object",
"properties": {
"categories": {
"items": { "$ref": "#/definitions/category" },
"type": "array"
},
"topics": {
"items": { "$ref": "#/definitions/topic" },
"type": "array"
}
}
}
当我在流行的在线验证器上使用此架构时,它不会捕获像 #/topics/5 或 #/ttt/555 这样的无效引用。
我可以使用此架构来验证引用吗?你能推荐我图书馆或服务吗?
【问题讨论】:
标签: json validation jsonschema