【问题标题】:How to use definitions from external files in JSON Schema?如何在 JSON Schema 中使用来自外部文件的定义?
【发布时间】:2018-03-05 10:10:56
【问题描述】:
我正在尝试使用 $ref 从另一个 json 架构导入定义,但出现以下错误:
can't resolve reference ../base/definitions.schema.json#/definitions/datetime from id #
{
"$schema": "http://json-schema.org/draft-06/schema#",
“定义”:{
“约会时间”: {
“类型”:“字符串”
},
“姓名”: {
“类型”:“字符串”
},
}
}
{
"$schema": "http://json-schema.org/draft-06/schema#",
“特性”: {
“活动”:{“类型”:“布尔”},
"created_at": { "$ref": "../base/definitions.schema.json#/definitions/datetime" },
“名称”:{“$ref”:“../base/base/definitions.schema.json#/definitions/name”},
“updated_at”:{“$ref”:“../base/definitions.schema.json#/definitions/datetime”}
},
“必需”:[“名称”],
“类型”:“对象”
}
目录结构:
api
- 根据
-- 定义.schema.json
- 国家
--国家.schema.json
我通过使用绝对路径、file url 和其他几种路径组合尝试了几种组合。不知道发生了什么。
架构验证器:ajv@5.1.1
【问题讨论】:
标签:
jsonschema
ajv