【发布时间】:2021-06-29 09:28:49
【问题描述】:
现在我有一个像这样的大型 json 架构
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "A example schema",
"definitions": {
"stringArray": {
"type": "array",
"items": { "type": "string" },
"uniqueItems": true,
"default": []
}
},
"properties": {
"time": {"type": "string", "minLength": 5},
"id": {"type": "integer"},
"members": {
"type": "array",
"items": {
"properties": {
"id": {"type": "string"},
"email": {"type": "string"}
}
}
}
}
}
以及使用它的新架构
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "A example schema",
"$ref": "example 1"
}
我想修改第二个模式,让一些字段支持空类型。
我正在考虑将第一个模式分成两部分,一个用于不支持 null 的部分,另一个用于需要支持 null 的部分。对于需要支持null的,我需要保留两份,一份支持null类型,一份不支持,因为它们都需要在不同的情况下。
不知道有没有更简单的方法来实现?
【问题讨论】:
标签: json jsonschema