Author:
Christopher Tse
Changed on:
16 Oct 2024
The Setting Schema is a JSON schema used by the Settings Component to provide metadata for a setting, helping to define its structure. This schema primarily describes the fields that the component will render, allowing for a no-code configuration experience within the Fluent platform.
The schema allows for various field types to be defined:
Type | Field |
String | Textfield |
Boolean | Switcher |
Number/Integer | Quantity Selector |
Array | Subform |
Object | Subform |
The title keyword can be placed in a field to give it a title.
See: https://json-schema.org/understanding-json-schema/reference/object#required
The required keyword can be used to mark which fields in an object are required.
This will be read by the settings component, and it will not allow the user to submit until all required fields have a value.
See: https://json-schema.org/understanding-json-schema/reference/enum
The enum keyword can be used to specify that a property or field can only have a limited pool of values. When the enum keyword is used, we expect an array of values that the property can take.
Currently, this is only supported for the string type.
When the enum property is specified, then the UI will switch to using a dropdown or radio input. If there are 3 or less options, then the radio input is used to select the option. Otherwise, a dropdown will be displayed instead.
1{
2 "$schema": "http://json-schema.org/draft-04/schema#",
3 "type": "object",
4 "properties": {
5 "letter": {
6 "title": "A letter",
7 "type": "string",
8 "enum": [
9 "A",
10 "B",
11 "C"
12 ]
13 }
14 }
15}
Language: json
Name: Schema with Enum
Description:
[Warning: empty required content area]The
`fcField`
The properties of each field will be passed to the field through the extensions prop. This allows you to extend the schema with your own props as needed. See the how-to guide for an example.
The
`default`
The value must be the same type as the field in question. Defaults are supported for all types, including objects and arrays. You can specify default values for arrays and objects in the same manner as primitives. However, the default value should adhere to the same structure as it would if defined in the setting.
Additionally, defaults also work for array items. Defaults for an array item's properties will be used for new items, as well as exisiting items that don't have that property in the setting.
All validation keywords are currently not supported.
Here are a few examples of schemas and what they represent
1{
2 "$schema": "http://json-schema.org/draft-04/schema#",
3 "type": "object",
4 "properties": {
5 "enableFeature": {
6 "title": "Turn on Feature X",
7 "type": "boolean"
8 }
9 }
10}
Language: json
Name: Schema
Description:
[Warning: empty required content area]1{
2 "$schema": "http://json-schema.org/draft-04/schema#",
3 "type": "object",
4 "properties": {
5 "enableNotifications": {
6 "title": "Enable order notifications",
7 "type": "boolean"
8 },
9 "maxNotifications": {
10 "title": "Maximum number of notifications to send per day",
11 "type": "integer"
12 },
13 "notificationMessage": {
14 "title": "Notification Message",
15 "type": "An order has been processed."
16 },
17 }
18}
Language: json
Name: Schema Sample
Description:
[Warning: empty required content area]1{
2 "$schema": "http://json-schema.org/draft-07/schema#",
3 "title": "Return Reasons",
4 "type": "array",
5 "items": {
6 "title": "This is a list of reasons that a store assistant may select when processing a return order. The label is the human readable string displayed in the dropdown menu and the value is the value sent to the orchestration engine when this option is selected.",
7 "type": "object",
8 "properties": {
9 "label": {
10 "title": "label",
11 "type": "string"
12 },
13 "value": {
14 "title": "Value",
15 "type": "string"
16 }
17 }
18 }
19}
Language: plain_text
Name: Schema Sample
Description:
Warning: this component only supports "items" as an schema object, array is not supported.
Scenarios where the component will not render (check the browser console for error messages):
- When context or contextId specified is invalid
- When schema or setting response has error
Copyright © 2024 Fluent Retail Pty Ltd (trading as Fluent Commerce). All rights reserved. No materials on this docs.fluentcommerce.com site may be used in any way and/or for any purpose without prior written authorisation from Fluent Commerce. Current customers and partners shall use these materials strictly in accordance with the terms and conditions of their written agreements with Fluent Commerce or its affiliates.