oneOf nested in array

302 Views Asked by At

I am currently testing JSON Forms on my schema (as is, without a UI definition), and I am running into the following problem: I can generate lists of options with oneOf (as shown in this_works below), but I am not able to do so within an array (this_does_not_work in the minimal example below). Instead, the array will simply offer simple text fields that validate against the options listed in oneOf.

Is there a way to achieve what I am trying to achieve here? Ideally, the UI of this_works (a list that users can select from) would appear for each line of the array:

{
    "$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"
                    }
                ]
            }
        }
    }
}```
0

There are 0 best solutions below