我目前正在我的架构上测试 JSON 表单(原样,没有 UI 定义),我遇到了以下问题:我可以生成选项列表oneOf
(如下所示this_works
),但我不能这样做在数组中(this_does_not_work
在下面的最小示例中)。相反,该数组将简单地提供简单的文本字段,这些字段根据 中列出的选项进行验证oneOf
。
有没有办法实现我在这里想要实现的目标?this_works
理想情况下,数组的每一行都会出现(用户可以从中选择的列表)的 UI :
{
"$id": "schema_test",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Minimal example",
"type": "object",
"properties": {
"this_works": {
"type": "string",
"oneOf": [
{
"const": "a",
"title": "Option A"
},
{
"const": "b",
"title": "Option B"
}
]
},
"this_does_not_work": {
"type": "array",
"items": {
"type": "string",
"oneOf": [
{
"const": "a",
"title": "Option A"
},
{
"const": "b",
"title": "Option B"
}
]
}
}
}
}```