【发布时间】:2020-03-27 10:56:25
【问题描述】:
我想根据 JSON 模式验证 JSON 文件,该模式使用 $ref 通过 URI 引用外部模式:
{
"$schema": "http://json-schema.org/schema#",
"$id": "https://reconciliation-api.github.io/specs/latest/schemas/manifest.json",
"type": "object",
"properties": {
"authentication": {
"$ref": "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v2.0/schema.json#/definitions/basicAuthenticationSecurity"
}
}
}
我希望验证器能够即时获取链接架构并使用它来验证我的 JSON。我曾为此尝试使用ajv-cli:
ajv test -s my_schema.json -r "\\\*" -d my_file.json
我希望-r "\\\*" 允许引用任何架构,但我收到以下错误:
error: can't resolve reference https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v2.0/schema.json#/definitions/basicAuthenticationSecurity
from id https://reconciliation-api.github.io/specs/latest/schemas/manifest.json#
ajv-cli 是否支持即时获取远程模式?如果没有,是否有任何其他验证器支持该功能?
【问题讨论】:
标签: json jsonschema ajv