【发布时间】:2021-04-23 13:05:01
【问题描述】:
我正在创建一个 json 模式来定义具有数据类型的必要数据。有一些数据需要设置到required 字段中。但在其文档中没有找到如何做到这一点。
对于这个 json 架构:
{
"type": "object",
"required": [
"version",
"categories"
],
"properties": {
"version": {
"type": "string",
"minLength": 1,
"maxLength": 1
},
"categories": {
"type": "array",
"items": [
{
"title": {
"type": "string",
"minLength": 1
},
"body": {
"type": "string",
"minLength": 1
}
}
]
}
}
}
json 喜欢
{
"version":"1",
"categories":[
{
"title":"First",
"body":"Good"
},
{
"title":"Second",
"body":"Bad"
}
]
}
我也想将title 设置为必需。它在一个子数组中。如何在 json schema 中设置?
【问题讨论】:
标签: arrays json schema jsonschema required