I have a json like this: {"mylist": ["a", "b", "c", "d", additional_element]}
additional_element could be one of the following four strings - "w", "x", "y", "z"; but not multiple
Examples:
{
"mylist": ["a", "b", "c", "d", "x"] // <-- valid
}
{
"mylist": ["a", "b", "c", "d", "x", "y"] // <-- not valid
}
How to write a jsonschema for this?
Current attempt:
{
"type":"object",
"properties":{
"mylist":{
"type":"array",
"items":{
"type":"string",
"enum":[
"a",
"b",
"c",
"d",
"w",
"x",
"y",
"z"
]
},
"minItems":1,
"uniqueItems":true
}
},
"required":[
"mylist"
],
"additionalProperties":false
}
Edit:
additional_element
- could be placed anywhere in the list.
- is optional
Additional examples:
{
"mylist": ["b", "a", "y"] // <-- valid
}
{
"mylist": ["z", "b", "a"] // <-- valid
}
{
"mylist": ["c"] // <-- valid
}
{
"mylist": ["y"] // <-- valid
}