Dynamic Form JSON Schema
JSON Schema
JSON Schema is a widely recognized standard, detailed at json-schema.org.
We support a select range of common features:
type
: Specifies the field’s type. For current support, see Type-Specific Keywords.- Presently, we only support single-type fields (
string
or an array containing a singlestring
item).- As an exception, fields with two types, where one is
null
(for example,["object", "null"]
), are also supported. Here,null
is disregarded, and the second type is considered primary. This adjustment accommodates our backend’s JSON Schema use.
- As an exception, fields with two types, where one is
- Supported types include:
- Presently, we only support single-type fields (
title
: A user-friendly label for a form field. For more information, see Generic Keywords.description
: Provides helpful information on filling out the form field. For further details, see Generic Keywords.
For specific features related to field types, please refer to the respective sections below.
Boolean Field
Full specification: JSON-Schema: Boolean
Supported features:
- …
Example:
{
"isDevelopment": {
"type": "boolean"
}
}
String Field
Full specification: JSON-Schema: String
Supported features include:
pattern
: Validates the string using a RegExp.minLength
: Specifies the minimum string length.maxLength
: Defines the maximum string length.examples
: Provides placeholder values. More details can be found here.enum
: Restricts the field to a set of predefined values. More information is available here.- Within an array, a String field with
enum
transforms into a MultiSelect component.
- Within an array, a String field with
Examples:
// Regular string field
{
"test": {
"type": "string",
"pattern": "^[A-Za-z0-9\\s]*$",
"minLength": 1,
"maxLength": 140,
"examples": ["value 1", "value 2"]
}
}
// String Select field
{
"method": {
"type": "string",
"enum": ["GET", "POST", "PUT", "DELETE"]
}
}
// String MultiSelect field
{
"method": {
"type": "array",
"items": {
"type": "string",
"enum": ["GET", "POST", "PUT", "DELETE"]
}
}
}
Numeric Field
Full specification: JSON-Schema: Numeric Types
Numeric fields can be either integer
(integral numbers) or number
(floating-point numbers).
Supported features:
multipleOf
: Ensures the field’s value is a multiple of the specified number.exclusiveMinimum
andexclusiveMaximum
: Specify values must be strictly less than or greater than a certain number.minimum
andmaximum
: Values must be less than or equal to, or greater than or equal to, specified numbers.examples
: Suggest placeholder values. For more details, see Examples.enum
: Limits the field to a set of specified values. Additional information at Enumerated Values.- A Numeric field with
enum
within an array becomes a MultiSelect component.
- A Numeric field with
Examples:
// Regular numeric field
{
"proxyTimeout": {
"type": "number",
"multipleOf": 10,
"minimum": 10,
"maximum": 1000,
"examples": [50, 120, 870]
}
}
// Numeric Select field
{
"proxyTimeout": {
"type": "number",
"enum": [10, 20, 30, 40, 50]
}
}
// Numeric MultiSelect field
{
"proxyTimeout": {
"type": "array",
"items": {
"type": "number",
"enum": [10, 20, 30, 40, 50]
}
}
}
Object Field
Full specification: JSON-Schema: Object
Supported features:
properties
: An object consisting of key-value pairs, where the key is the field name (sent to the backend), and the value is one of the supported field types.required
: An array listing the keys that must be provided.
Example:
{
"server": {
"type": "object",
"properties": {
"isBackup": { "type": "boolean" },
"weight": { "type": "integer" },
"service": { "type": "string" }
},
"required": ["service"]
}
}
Array Field
Full specification: JSON-Schema: Array
Supported features:
minItems
andmaxItems
: Define the minimum and maximum number of items in the array.uniqueItems
: Specifies if the array should contain unique items.
Example:
{
"headers": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"value": { "type": "string" }
},
"required": []
}
}
}
Last modified April 16, 2024