Schema.json for Custom Lightning Types
The schema.json file uses the JSON Schema Specification to define your custom Lightning type. The schema consists of a specific set of keywords that apply constraints to the data.
Schema for Apex-Based Custom Lightning Types
For Apex-based types, the schema references an Apex class. You don’t define properties here. Instead, you point to the class that contains the data structure.
This table lists the keywords that you can specify in a schema.json file.
| Keyword | Required or Optional | Type | Description |
|---|---|---|---|
title | Required | String | Name for the Lightning type |
description | Optional | String | Description for the Lightning type |
lightning:type | Required | String | Refers to @apexClassType types by using fully qualified names.This keyword is syntactic sugar for the $ref keyword in JSON Schema, which links together schemas.For information about $ref, see Understanding JSON Schema: The Sref keyword |
Unless noted otherwise, the keywords follow the JSON Schema specification.
Here’s a sample code that shows the contents of the schema.json file for a custom Lightning type flightResponse.
Schema for Object-Based Custom Lightning Types
For object-based types, you define the data structure directly in the schema.json file by using the lightning__objectType value and a properties block.
You can create object-based custom Lightning types only in Prompt Builder to structure prompt template output.
This table lists the keywords that you can specify in a schema.json file.
| Keyword | Required or Optional | Type | Description |
|---|---|---|---|
title | Required | String | Name for the Lightning type |
description | Optional | String | Description for the Lightning type |
lightning:type | Required | String | Refers to lightning__objectType type by fully qualified name |
properties | Required | Object | Defines the fields for the object. Each key is a field name, and its value is an object defining that field’s title and lightning:type.Supported lightning:type values include:
|
required | Optional | Array | An array of property names that must be present in the data |
Here’s a sample code that shows the contents of the schema.json file for a custom Lightning type customerFeedback.
When you create or update an object-based custom Lightning type, an Apex class is automatically generated that matches your schema.
You can customize labels for the title and description values in the schema.json file for a custom Lightning type.
To create and use a translated custom label in a custom Lightning type, complete these steps.
- From Setup, enter
Labelsin the Quick Find box, and then select Custom Labels. - Create a custom label.
- In the
schema.jsonfile for the custom Lightning type that you created, use the expression{!$Label.c.MyLabel1}for the title and description values. Here, “c” is the namespace prefix and “MyLabel1” is the API name of the custom label.
See Also