我正在我的节点.js项目中使用 AJV 包。
我正在尝试根据几个架构文件验证一些数据。这两个架构文件位于同一目录中:
/dir
|
parent_schema.json
|
sub_schema.json
/data
|
data.json
我试图得到一个超级简单的例子,但我遇到了麻烦。 看来:$refparent_schema.json
{
"properties": {
"foo": { "type": "string" },
"bar": { "$ref": "sub_schema.json" }
}
}
看起来像这样:sub_schema.json
{
"properties": {
"sub1": { "type": "string" },
}
}
为了完整起见,我试图验证我的:如下所示:data.json
{
"foo": "whatever",
"bar": {
"sub1": "sometext"
}
}
我遇到的问题是我的道路。我从 AJV 收到此错误:$ref
MissingRefError {
message: "can't resolve reference subschema1.json from id #"
missingRef: "subschema1.json"
missingSchema: "subschema1.json"
}
有人看到我的道路出了什么问题吗?我知道您还应该使用 来选择要匹配的特定属性,但我希望使用整个架构。#
缥缈止盈
相关分类