# Enriching enum values with UISchema

**URL:** <https://jsonforms.discourse.group/t/enriching-enum-values-with-uischema/12>\
**Category:** General\
**Created:** [June 2, 2021, 10:23pm UTC](https://jsonforms.discourse.group/t/enriching-enum-values-with-uischema/12 "2021-06-02T22:23:14Z")\
**Posts on this page:** 2\
**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:** [June 2, 2021, 10:23pm UTC](https://jsonforms.discourse.group/t/enriching-enum-values-with-uischema/12/1 "2021-06-02T22:23:14Z")

</div>

Is there a way or has your team considered giving the ability to enrich enum values with data that would naturally belong in the UI schema? Currently you can do a small bit of this by attaching a label to enum values using the oneOf and const/title strategy, but this feels kind of strange when trying to follow the paradigm of schema and UI schema. For instance what if I have some enum values but with each one I not only want a label but an image, description, and color. There is already some magic going on within the system that is mapping oneOf or enum entries to the options prop of renderers, so I am suggesting a way to add more data to each object in the options array. There are a few ways this could be done in the UI schema, probably by having a map that is keyed by enum values. I know this can be done manually with the options property of the UI schema paired with a function that can look up each enum value’s uischema, but it seems like it could be a good fit to add to one of these with context hooks. Thoughts?

_[[original thread](https://spectrum.chat/jsonforms/general/enriching-enum-values-with-uischema~ec533a57-05cf-4027-a46e-ff23743e0684) by Chad Johnson]_

---

<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:** [June 5, 2021, 10:56am UTC](https://jsonforms.discourse.group/t/enriching-enum-values-with-uischema/12/2 "2021-06-05T10:56:14Z")

</div>

Hi @chad-johnson(chad-johnson), I can see where you’re coming from. For example it definitely makes sense to also map `description` from the JSON Schema into the enum options.

I’m not that sure about properties like `image` or `color`. When using these you will need to write a custom renderer anyway. You have the `uischema` element already accessible within the custom renderer so you can just map these options in the way you need it.

When I understand you correctly, you’re suggesting something like this:

```auto
type: 'Control',
enumOptions: [
  {
    image: 'image',
    color: '#000000'
   },
  {
    image: 'image2',
    color: '#000001'
   },
]

```

which then maps each of these options per index to the one in JSON Schema.

I guess the main benefit would be that we could also overwrite labels like this, so the user no longer needs to write `oneOf` for enums or even when using them could still overwrite them via the ui schema.

If you’d like you can open a feature request in our repository.
