# General: How do we define a boundary between schema and uiSchema

**URL:** <https://jsonforms.discourse.group/t/general-how-do-we-define-a-boundary-between-schema-and-uischema/190>\
**Category:** General\
**Created:** [July 15, 2019, 8:53am UTC](https://jsonforms.discourse.group/t/general-how-do-we-define-a-boundary-between-schema-and-uischema/190 "2019-07-15T08:53:57Z")\
**Posts on this page:** 9\
**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:** [July 15, 2019, 8:53am UTC](https://jsonforms.discourse.group/t/general-how-do-we-define-a-boundary-between-schema-and-uischema/190/1 "2019-07-15T08:53:57Z")

</div>

I have a general question. How do we decide if an option for a property will go in schema or ui-schema? Let’s say I have to specify options for the select input, right now I have to specify it on enum property in the schema but someone may say that It should be part of ui-schema. There are other examples as well. e.g labels for the groups and inputs, specifying options for the array, specifying the max and min rows for the input area etc.

Are there any general guidelines to follow while deciding on what goes where?

_[[original thread](https://spectrum.chat/jsonforms/general/general-how-do-we-define-a-boundary-between-schema-and-uischema~df288366-cca3-4d59-a59e-491abbb5d434) by shivgarg5676]_

---

<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:** [July 15, 2019, 9:08am UTC](https://jsonforms.discourse.group/t/general-how-do-we-define-a-boundary-between-schema-and-uischema/190/2 "2019-07-15T09:08:23Z")

</div>

Information describing the data itself should be part of the JSON schema, while information describing how the data shall be rendered should be part of the ui schema. For some information there will always be a grey area where one could argue for either schema.

In general I would like to recommend to stick to the [JSON Schema specification](https://json-schema.org/specification.html) for the JSON Schema. Therefore if a feature you want to implement can be represented in your JSON Schema then go for it. Adding it there in a clean way may enable further use cases later on with JSONForms or other frameworks.

If there is no clean way to integrate it in JSON Schema feel free to adapt your UI schemas to your liking. If you want to stay compatible to JSONForms as far as possible I would like to recommend adding entries to the options object of each control. However you can of course adapt / change the whole UI schema if needed.

If a concept can’t be represented cleanly in either schema you could also implement your own additional format and process it in your renderers.

These are just general guidelines. As always those may or may not fit your specific use cases and requirements. If you want to discuss a specific example feel free to describe it here or in a new question.

---

<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:** [July 15, 2019, 9:32am UTC](https://jsonforms.discourse.group/t/general-how-do-we-define-a-boundary-between-schema-and-uischema/190/3 "2019-07-15T09:32:33Z")

</div>

_[shivgarg5676]_

Thanks @sdirix for clarification over here. That explains a lot of things.

---

<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:** [July 15, 2019, 9:38am UTC](https://jsonforms.discourse.group/t/general-how-do-we-define-a-boundary-between-schema-and-uischema/190/4 "2019-07-15T09:38:25Z")

</div>

_[shivgarg5676]_

If I talk about string type element then we(jsonform) has properties like “description” to be specified in the schema. But if we see json-schema specification for type string there is no such property called description. So I got confused that if that should be part of schema or ui-schema.  
But `Therefore if a feature you want to implement can be represented in your JSON Schema then go for it. Adding it there in a clean way may enable further use cases later on with JSONForms or other frameworks` quote explained the particular use case. Am I right?

---

<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:** [July 15, 2019, 9:58am UTC](https://jsonforms.discourse.group/t/general-how-do-we-define-a-boundary-between-schema-and-uischema/190/5 "2019-07-15T09:58:13Z")

</div>

_[shivgarg5676]_

More to this, I recently implemented functionality to sort arrays. For that I added the option named `showSortButtons` in the ui schema. Would have it been better if I had placed an option in schema itself for type array something like this

```auto
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "label": {
                "type": "string"
            },
            "iconSlug": {
                "type": "string"
            }
        },
        "required": [
            "label",
            "iconSlug"
        ]
    },
    "options": {
        "isSortable": false
    }
}

```

---

<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:** [July 15, 2019, 9:59am UTC](https://jsonforms.discourse.group/t/general-how-do-we-define-a-boundary-between-schema-and-uischema/190/6 "2019-07-15T09:59:24Z")

</div>

The `title` and `description` keywords are part of the [JSON Schema Validation Specification](https://json-schema.org/latest/json-schema-validation.html#rfc.section.10.1). Note that many frameworks supporting JSON Schema are actually supporting [JSON Schema Core](https://json-schema.org/latest/json-schema-core.html) + [JSON Schema Validation](https://json-schema.org/latest/json-schema-validation.html).

If title and description would not be part of JSON Schema I would have recommend adding them to the UI schema to avoid using an unspecified keyword in JSON Schema.

---

<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:** [July 15, 2019, 10:12am UTC](https://jsonforms.discourse.group/t/general-how-do-we-define-a-boundary-between-schema-and-uischema/190/7 "2019-07-15T10:12:46Z")

</div>

_[shivgarg5676]_

Got it, Then array implementation was right. Thanks!!

---

<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:** [July 15, 2019, 10:16am UTC](https://jsonforms.discourse.group/t/general-how-do-we-define-a-boundary-between-schema-and-uischema/190/8 "2019-07-15T10:16:14Z")

</div>

As I don’t know of any way to specify this functionality within JSON Schema I would like to recommend to add it to the UI schema. Note that we already implemented functionality for manual sorting which can be enabled with `showSortButtons: true` in the options field of an array control. You can also check the `array-with-detail`[example](https://github.com/eclipsesource/jsonforms/blob/2dafd1163c6f7c855afea80f40342cee14f53fd2/packages/examples/src/arrays-with-detail.ts#L60).

---

<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:** [July 15, 2019, 10:18am UTC](https://jsonforms.discourse.group/t/general-how-do-we-define-a-boundary-between-schema-and-uischema/190/9 "2019-07-15T10:18:45Z")

</div>

Glad to help! Just to clarify: I would recommend adding your sorting option to the UI schema, not the JSON schema. So I would not use the JSON Schema you showcased above.
