【发布时间】:2016-04-23 16:25:58
【问题描述】:
我对在模式中复制键有疑问。这是一个例子:
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 验证器不允许值是布尔值,我在 JSON 规范中搜索了很多,但没有关于它的信息。
【问题讨论】:
标签: json jsonschema json-schema-validator