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.

KeywordRequired or OptionalTypeDescription
titleRequiredStringName for the Lightning type
descriptionOptionalStringDescription for the Lightning type
lightning:typeRequiredStringRefers 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.

KeywordRequired or OptionalTypeDescription
titleRequiredStringName for the Lightning type
descriptionOptionalStringDescription for the Lightning type
lightning:typeRequiredStringRefers to lightning__objectType type by fully qualified name
propertiesRequiredObjectDefines 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:
  • lightning__textType
  • lightning__numberType
  • lightning__integerType
  • lightning__booleanType
  • lightning__dateType
  • lightning__dateTimeStringType
  • lightning__timeType
requiredOptionalArrayAn 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.

  1. From Setup, enter Labels in the Quick Find box, and then select Custom Labels.
  2. Create a custom label.
  3. In the schema.json file 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