# oneOf nested inside array

**URL:** <https://jsonforms.discourse.group/t/oneof-nested-inside-array/107>\
**Category:** General\
**Created:** [February 11, 2021, 10:23am UTC](https://jsonforms.discourse.group/t/oneof-nested-inside-array/107 "2021-02-11T10:23:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [February 11, 2021, 10:23am UTC](https://jsonforms.discourse.group/t/oneof-nested-inside-array/107/1 "2021-02-11T10:23:20Z")

</div>

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:

```auto
{
    "$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](https://spectrum.chat/jsonforms/general/oneof-nested-inside-array~64b83afc-7124-42fe-b76a-5c0b3de93e6e) by Andreas Walker]_

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [February 12, 2021, 4:17pm UTC](https://jsonforms.discourse.group/t/oneof-nested-inside-array/107/2 "2021-02-12T16:17:01Z")

</div>

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:

```auto
{
  "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](https://github.com/eclipsesource/jsonforms/issues/1692)

---

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [February 15, 2021, 7:52am UTC](https://jsonforms.discourse.group/t/oneof-nested-inside-array/107/3 "2021-02-15T07:52:45Z")

</div>

_[Andreas Walker]_

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