gpt4 book ai didi

jsonschema - 如何将 JSON Schema $ref 解析为父目录中的文件

转载 作者:行者123 更新时间:2023-12-05 07:35:05 25 4
gpt4 key购买 nike

我有一些遗留的 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 位于 ../相对于上面的 child 。

{
"$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。

最佳答案

代替:

    "properties": {
"query": { "$ref": "../query.json#/query" }
},

尝试:

    "properties": {
"query": { "$ref": "../query.json
},

如果您要链接到该文件中的特定属性,请尝试:

    "properties": {
"query": { "$ref": "../query.json#/properties/[name of property]" }
},

关于jsonschema - 如何将 JSON Schema $ref 解析为父目录中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49763511/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com