0

我有一些 js 对象的草稿 -03 json 模式。

我正在使用 z-schema https://github.com/zaggino/z-schema来验证 js 对象的模式。

我在它的 api 的帮助下设置远程引用,setRemoteReference并从这里 http://json-schema.org/draft-03/schema#提供 Draft-03 模式对象

var ZSV = new ZSchemaValidator({ breakOnFirstError: false });
ZSV.setRemoteReference('http://json-schema.org/draft-03/schema#', {
  // json object downloaded from draft-03 url
});

但是我调用 validate 方法会引发错误

[{"code":"REMOTE_NOT_VALID","params":["http://json-schema.org/draft-03/schema#"],"message":"Remote reference didn't compile successfully: http://json-schema.org/draft-03/schema#","path":"#/uri(http://json-schema.org/draft-03/schema)","inner":  ....

好像编译失败了。但是,从真实来源http://json-schema.org/draft-03/schema#下载的模式对象怎么会出错。?

还是说,z-schema 无法有效地编译 draft-03。?

所以我的问题是,我如何使用 z-schema 验证 draft-03?

4

1 回答 1

0

如果问题是在 v4 工具中使用 v3 模式,那么您可以尝试json-schema-compatibility

它将模式标准化为 v4 - v3 模式已更新,v4 模式未更改。

(完全披露:我编写了工具)

于 2015-03-30T13:29:32.863 回答