我有以下 JSON 模式:
模式 A:
{
"$schema": "http://json-schema.org/draft-04/hyper-schema#",
"title": "A",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"entityBId": {
"type": "string"
}
},
"required": [
"name",
"entityBId"
],
"links": [
{
"rel": "B",
"href": "myapi/EntityB?id={entityBId}"
}
]
}
模式 B:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "B",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"name"
]
}
我试图弄清楚是否有一种方法可以运行基于带有外部链接/引用的 JSON Schema 的完整性检查之类的东西。例如:当我收到entityBId = 1 的对象 A 时,我想在链接 href 中声明的端点中获取运行 GET 的实体 B,并检查接收到的 id 中是否存在有效对象。它将像深度验证一样运行,并且在没有定义数据库模式的场景中很有用。