Environment Manager - Schema Examples - Rafay Product Documentation

Data Schema and UI Schema Examples

Overview

The following examples demonstrate how to generate Data Schema and UI Schema using the React JSON Schema Form Builder. Each example outlines the process of defining input data, creating corresponding form elements, and converting the schema into the required JSON format. These steps help structure data for various configurations, ensuring compatibility with form-based user interfaces.


Access the Tool

Add Form Elements

Example 1

Object 1

Object 2

Once the form is designed, switch to the Edit Schema tab

Convert Data Schema and UI Schema to JSON Format

The DataSchema and UI Schema are ready, but neither of the schemas is in JSON format.

To convert the schemas (JavaScript object) into JSON format, use:

Final Output

After conversion, both the Data Schema and UI Schema will be in JSON format, ready for implementation

DataSchema

{
  "type": "object",
  "title": "Machine Configuration",
  "description": "Select the type of machine for deployment.",
  "properties": {
    "machine_type": {
      "enum": [
        "e2-standard-2",
        "e2-standard-4",
        "n2-standard-2",
        "n2-standard-4"
      ],
      "title": "Machine Type",
      "type": "string"
    },
    "test_data": {
      "title": "Test Data",
      "type": "string"
    }
  },
  "dependencies": {},
  "required": [
    "machine_type",
    "test_data"
  ]
}

UI Schema

{
  "ui:order": [
    "machine_type",
    "test_data"
  ]
}

Example 2

Object 1

Object 2

Object 3

Once the form is designed, switch to the Edit Schema tab

Convert Data Schema and UI Schema to JSON Format

The Data Schema and UI Schema are ready, but neither of the schemas is in JSON format.

To convert the schemas (JavaScript object) into JSON format, use:

Final Output

After conversion, both the Data Schema and UI Schema will be in JSON format, ready for implementation

DataSchema

{
  "type": "object",
  "title": "Config Form",
  "description": "Config Input Variable Form",
  "properties": {
    "instance_type": {
      "enum": [
        "t3.micro",
        "t3.small",
        "t3.large"
      ],
      "title": "Instance Type",
      "type": "string"
    },
    "aws_region_az": {
      "enum": [
        "us-east-1a",
        "us-east-1b",
        "us-west-1c"
      ],
      "title": "AWS Region AZ",
      "type": "string"
    },
    "email_id": {
      "title": "Email ID",
      "type": "string"
    }
  },
  "dependencies": {},
  "required": []
}

UI Schema

{
  "ui:order": [
    "instance_type",
    "aws_region_az",
    "email_id"
  ]
}

Apply Schema in Controller

Once the schemas are ready, users can use them in Environment Manager -> Config Context -> Input Variables

💡 Note: The user must provide schemas only if they intend to use the input variable as part of the config context in actions. The Data Schema is mandatory, while the UI Schema is optional.