我想用JSON模式数组来描述,该数组应包含零个或多个预定义值.为简单起见,让我们这些可能的值:one,two和three.
正确的数组(应该通过验证):
[]
["one", "one"]
["one", "three"]
Run Code Online (Sandbox Code Playgroud)
不正确:
["four"]
Run Code Online (Sandbox Code Playgroud)
现在,我知道"enum"应该使用该属性,但我找不到相关信息放在哪里.
选项A(下"items"):
{
"type": "array",
"items": {
"type": "string",
"enum": ["one", "two", "three"]
}
}
Run Code Online (Sandbox Code Playgroud)
选项B:
{
"type": "array",
"items": {
"type": "string"
},
"enum": ["one", "two", "three"]
}
Run Code Online (Sandbox Code Playgroud)