我对在模式中复制键有疑问。这是示例:
main.schema.json
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"main.schema": {
"properties": {
"value": {
"description": "Status",
"type": "boolean"
}
},
"type": "object"
}
},
"allOf": [
{
"$ref": "baseResource.json#/definitions/baseResource"
},
{
"$ref": "#/definitions/main.schema"
}
],
"id": "main.schema.json#",
"required": [
"value"
],
"title": "Title",
"type": "object"
}
baseResource.json
{
"$schema": "http://json-schema.org/draft-04/schema#",
"allOf": [
{
"$ref": "#/definitions/baseResource"
}
],
"definitions": {
"baseResource": {
"properties": {
"id": {
"description": "SomeDesc",
"type": "string"
},
"value": {
"type": [
"string",
"boolean"
]
}
},
"type": "object"
}
},
"id": "baseResource.json#",
"required": [
"id"
],
"title": "Base Resource",
"type": "object"
}
什么类型的值适合这个?值应该只是布尔值(根据主模式)或者可以是布尔值或字符串(引用正确的基本资源)。我正在使用 JSON 验证器,它不允许 value 为布尔值,我在 JSON specyfication 中搜索了很多,但没有关于它的信息。