我不明白如何正确引用其他架构。我使用了 ajv,并且有接下来的两个模式
第一个架构不正确-email.json:
{
"title": "Не корректный email",
"properties": {
"status": {
"description": "Статус операции",
"type": "integer",
"enum": [68]
},
"error": {
"$ref":"error.json"
}
},
"required":["status", "error"],
"additionalProperties": false
}
第二个模式error.json:
{
"type": "array",
"minItems": 2,
"items": {
"type": "object",
"properties": {
"description_ru": {
"description": "Информация об ошибке на русском языке",
"type": "string"
},
"description_en": {
"description": "Информация об ошибке на английском языке",
"type": "string"
}
},
"additionalProperties": false
}
}
运行测试后我得到这个错误
Error: can't resolve reference error.json from id # Mine 验证方法:
var valid = ajv.validate(require("../schema/login/incorrect-email.json"), data);
我需要参考本地架构 error.json,而不是远程服务器等。请告诉我,我可以在此架构中添加 id 和 $ref 以使用 ajv 正确解析