Skip to main content

Extension Definition Schemas

The schema property of an extension-definition specifies the structure and type of the values the extension can hold. Extension schemas use JSON Schema, but with important restrictions:
  1. Only static sub-schemas are allowed Property types cannot be freely defined. Instead, they must reference one of the static schemas exposed at the /lucca-api/schemas endpoint. You must declare these references using $ref.
  2. Objects are only supported at the root Nested objects (objects as child properties) are not supported. The root schema may be of type object, but its properties must still use $ref to point to allowed sub-schemas.
When you create an extension-definition (POST), you provide a $ref to the relevant static schema. When you fetch an extension-definition (GET), the API may either return the raw $ref or inline transclude the full definition of the referenced schema.

Examples

Taxonomies and Taxonomy Labels

Some extension values are not primitive types but instead must be chosen from a user-defined list. These lists are modeled through the taxonomies and taxonomy-labels API endpoints:
  • Taxonomies represent the named lists themselves (e.g. T-Shirt sizes).
  • Taxonomy-labels represent the individual values within a taxonomy (e.g. Small, Medium, Large).
Both taxonomies and taxonomy-labels can be retrieved, created and updated through their own API endpoints.

Using Taxonomies in Extension Definitions

When an extension value should be restricted to a taxonomy-label, the extension’s schema must reference the static schema: In addition, the extension-definition must declare which taxonomy it refers to. This is done by including a taxonomy property at the root of the extension-definition object, alongside schema. Without this taxonomy reference, the system would not know which set of labels to use for validation.
In this example:
  • The schema restricts values to a taxonomy label reference.
  • The taxonomy.id identifies which taxonomy provides the allowed labels (e.g. the list of T-Shirt sizes).