【发布时间】:2021-09-28 16:05:44
【问题描述】:
尝试对所有属性使用 $ref。我不知道这是什么语法有效,但不验证有效负载。这应该会失败,但不会。
我也试过 "$ref": "file:./ref.json"。
架构:
{
"animal": {
"properties":{
"allOf": {"$ref": "file:./ref.json"}
}
},
"required": ["animal"]
}
ref.json:
{
"action":{
"type": "string"
},
"required": ["action"]
}
有效载荷
{
"animal": {
"action": 2
}
}
【问题讨论】:
-
看起来您是 JSON Schema 的新手。我建议json-schema.org/learn/getting-started-step-by-step.html 进行快速介绍,json-schema.org/understanding-json-schema 进行温和但更深入的潜水。
标签: json jsonschema json-schema-validator