我有一些遗留的draft-04架构,我试图将$ ref解析为父目录中的文件。在各种虚线路径上的几次尝试都未能为我解决这个问题。
儿童架构
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "emailDelivery/delivery.delivery.config.emailSituations",
"description": "desc",
"type": "array",
"items": {
"description": "desc",
"type": "object",
"allOf": [
{ "$ref": "delivery.delivery.config.meta" }
],
"properties": {
"name": {
"description": "desc",
"type": "string"
},
"conditions": {
"description": "Wraps a query object",
"type": "object",
"properties": {
"query": { "$ref": "../query.json#/query" }
},
"required": [ "query" ]
},
"body": {
"description": "The body of the email message",
"type": "string"
}
},
"required": [ "name", "conditions", "body" ]
}
}
Query.json位于../相对于上面的孩子。
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "query",
"description": "desc",
"type": ["object", "null"],
"properties": {
"operator": {
"description": "desc",
"enum": [ "and", "or" ]
},
"rules": {
"description": "Tdesc",
"type": "array",
"items": {
"anyOf": [
{ "$ref": "#/definitions/comparisonRule" },
{ "$ref": "#/definitions/groupRule" }
]
}
}
},
"required": [ "operator", "rules" ],
"definitions": {
"comparisonRule": {
"description": "desc",
"type": "object",
"properties": {
"field": {
"description": "desc",
"type": "string"
},
"comparison": {
"description": "desc",
"enum": [ "is", "is not", "greater than", "less than" ]
},
"data": {
"description": "desc",
"type": [ "array", "string" ],
"items": {
"description": "desc",
"type": "string"
}
}
},
"required": [ "field", "comparison", "data" ]
},
"groupRule": {
"description": "desc",
"type": "object",
"properties": {
"query": { "$ref": "query" }
},
"required": [ "query" ]
}
}
}
我收到的错误:
Error: can't resolve reference file:../query.json#/query from id emailDelivery/delivery.delivery.config.emailSituations#
根据我的理解,此路径应适用于../ query.json。