oneOf nested inside array

Dear all, 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, but I am not able to do so within an array. Have a look at the minimal example below. Is there a way to achieve what I am trying to achieve here? Ideally, the UI of “this_works” (list for selection) 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"
                    }
                ]
            }
        }
    }
}

[original thread by Andreas Walker]

Hi @andreaswalker(andreaswalker), this is a bug / missing feature in JSON Forms. The problem is that we don’t provide a cell renderer which can handle the special oneOf enums. Therefore it falls back to a normal string-cell because of the type: ‘string’ in the array items.

As a workaround you can use the non-table rendering of the array and therefore use the usual oneOf enum renderer for controls. You can do this by either removing the type: ‘string’ in the items property of the array in the JSON Schema or by specifying in the ui schema that you would like to use the non-table variant:

{
  "type": "VerticalLayout",
  "elements": [
    {
      "type": "Control",
      "scope": "#/properties/this_does_not_work",
      "options": {
        "detail": "Generated"
      }
    }
  ]
}

We should add an oneOf enum cell renderer to our renderer set so we can have them in tables too. I opened a ticket for this: #1962

[Andreas Walker]

Hello @sdirix(sdirix), thank you for the reply, and for putting it on a ticket - I’ll give the workaround a try.