Extension Definition Schemas
Theschema 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:
- 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. - 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
$refto point to allowed sub-schemas.
$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).
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 ataxonomy-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.
- The
schemarestricts values to a taxonomy label reference. - The
taxonomy.ididentifies which taxonomy provides the allowed labels (e.g. the list of T-Shirt sizes).