Property types
Property | Description |
---|---|
String | Basic string mapping. Accepts the following fields: type value default Note: type and value are required if you aren't using the shorthand - e.g. "title": "{p.headline}" |
Number | Basic number or integer mapping. Required fields: type value Optional fields: default precision |
Boolean | Basic boolean mapping. Required fields: type value Optional fields: default |
Array | Mapping of an array, defining the input to iterate and the items definition. Required fields: type input items Optional fields: var |
Object | Mapping of an object. Required fields: type properties |
Reference | Referencing another schema. Required fields: type alias - use id OR originId Optional fields: source |
Partial | Referencing a partial schema to map the data into. Required fields: type input alias |
Dynamic | Dynamic mapping using the path selector. Required fields: * |
There is no Date
property type. But if you ingest your dates as strings in the following format yyyy-MM-ddTHH:mm:ss
, you can still sort by date and the value can easily be parsed to Date on the client in JavaScript and other languages.
string
Basic string mapping.
Since string is the most commonly used property type you can access it without writing the type
and value
property. This is meant as syntactic sugar making it easier and quicker to work with.
Fields
Property | Required? | Description |
---|---|---|
type | Yes | The property type - here string |
value | Yes | The value of the property |
default | No | The default value is used if value is null or an empty string |
Examples
"title": "{p.headline}"
"title": {
"type": "string",
"value": "{p.headline}",
"default": "Unknown title"
}
number
Basic number or integer mapping.
The size of the number is limited to the size of a C# double.
Fields
Property | Required? | Description |
---|---|---|
type | Yes | The property type - here number |
value | Yes | The value of the property |
default | No | The default value is used if value is null or can be parsed as a number |
precision | No | Rounds a decimal value to a specified number of fractional digits, and rounds midpoint values to the nearest even number. Default value is 0 |
Examples
"stock": {
"type": "number",
"value": "{p.inventoryQuantity}"
}
boolean
Basic boolean mapping.
Fields
Property | Required? | Description |
---|---|---|
type | Yes | The property type - here boolean |
value | Yes | The value of the property |
default | No | The default value is used if value is null or can be parsed as a boolean |
Examples
"isPublished": {
"type": "boolean",
"value": "{p.published}",
"default": true
}
array
Mapping of an array, defining the input to iterate and the items definition.
Array property type is designed for working with collections.
Fields
Property | Required? | Description |
---|---|---|
type | Yes | property type - here array |
input | Yes | States input, where to retrieve items collection to work with from. Support input types: string $exp $lookup |
items | No | Used for mapping results. |
var | No | Collection iteration variable name. Default value is - item . |
string
type
A simple example showing how to use a string
type in items
.
"categories": {
"type": "array",
"input": "{p.categories}",
"items": {
"type": "string",
"value": "{item}"
}
},
$exp
input
With expression input, you can reference the desired property on the source entity that is an array.
"tabs": {
"type": "array",
"input": "{p.tabs}",
"var": "tab",
"items": {
"type": "object",
"properties": {
"title": "{tab.title}",
"content": "{tab.content}"
}
}
}
$path
input
With path input, you can select the desired items on the source entity using the path selector.
"tabs": {
"type": "array",
"input": {
"$path": "p.tabs[*]"
},
"var": "tab",
"items": {
"type": "object",
"properties": {
"title": "{tab.title}",
"content": "{tab.content}"
}
}
}
Filter items:
"tabs": {
"type": "array",
"input": {
"$path": "p.tabs[?(@.display==true)]"
},
"var": "tab",
"items": {
"type": "object",
"properties": {
"title": "{tab.title}",
"content": "{tab.content}"
}
}
}
$lookup
input
Lookup input comparing to $exp allows you to define query-like and criteria match source entities lookup conditions.
$lookup
with single property value match
Property | Required? | Description |
---|---|---|
operator | Yes | The operator for the lookup. Supported operators: equals contains |
sourceEntityProperty | Yes | The property to match the value on |
matchValue | Yes | The value to match the sourceEntityProperty |
sourceEntityType | No | Type of source entity to use for lookup. Default value is include all entity types available: * |
orderBy | No | Allows you to specify your desired sorting order |
top | No | Allows limiting the size of items collection. Can be a number, a number as a text, or an expression. |
source | No | Allows you to define a different source as the property. The source should be equal to the desired source group alias, where you want to look for source entities.If not defined, it uses the current source group. |
"navigationItems": {
"type": "array",
"input": {
"$lookup": {
"operator": "equals",
"sourceEntityType": "*",
"sourceEntityProperty": "originParentId",
"matchValue": "{originId}",
"orderBy": {
"property": "properties.metaData.sortOrder",
"sort": "asc"
},
"top": 5
}
},
"items": {
"type": "reference",
"id": "{input.id}",
"alias": "NavigationItem"
}
}
$lookup
with filter
Particular lookup filter type allows you to be more flexible with your matching criteria.
Property | Required? | Description |
---|---|---|
filter | Yes | Your filtering criteria. See list of filter examples |
orderBy | No | Allows you to specify your desired sorting order |
top | No | Allows limiting the size of items collection. Can be a number, a number as a text, or an expression. |
source | No | Allows you to define a different source as the property. The source should be equal to the desired source group alias, where you want to look for source entities.If not defined, it uses the current source group. |
Additional
Arrays have some additional properties available:
-
root
For schemas it will contain the source entity and for partial schemas the input. It is possible to access everything from the source entity likeroot.originId
orroot.properties.headline
. All property values initems
that supports expressions can accessroot
."tabs": {
"type": "array",
"input": "{p.tabs}",
"var": "tab",
"items": {
"type": "object",
"properties": {
"title": "{root.p.headline}: {tab.title}",
"content": "{tab.content}"
}
}
} -
parent
If having multidimensional arraysparent
can be used to access items of the parent array. For the first arrayparent
will be equal toroot
. For the next levelsparent
will be equal toitem
of the parent array. All property values initems
that supports expressions can useparent
."tabs": {
"type": "array",
"input": "{p.tabs}",
"var": "tab",
"items": {
"type": "object",
"properties": {
"title": "{tab.title}",
"content": "{tab.content}",
"subTabs": {
"type": "array",
"input": "{tab.tabs}",
"var": "subTab",
"items": {
"title": "{parent.title}: {subTab.title}",
"content": "{subTab.content}",
}
}
}
}
}
object
Mapping of an object.
Fields
Property | Required? | Description |
---|---|---|
type | Yes | The property type - here object |
properties | Yes | The properties of the object |
Examples
"item": {
"type": "object",
"properties": {
"title": "{p.title}",
"content": "{p.content}"
}
}
reference
Referencing another schema.
The reference property type is a bit different than string, number, boolean, etc.
This property types allows referencing other views created from either this Source Entity or from another source entity.
When referenced Enterspeed will resolve the view when requested by the Delivery API, so that the data will stay up-to-date.
In order to reference desired source entity, you can use alias
of the schema and id
or originId
of the source entity and optionally a different source than the current source entity.
Reference schemas are typically used when you are mapping data from another entity. Eg. a page has a reference another page entity or media entity.
Read more about reference schemas here
Fields
Property | Required? | Description |
---|---|---|
type | Yes | The property type - here alias |
alias | Yes | The alias of the schema you wish to reference |
id | Yes / No | The id of the source entity. originId can be used instead |
originId | Yes / No | The originId of the source entity. id can be used instead |
source | No | Allows you to define a different source. The source should be equal to the desired source group alias, where the view is located. If not defined, it uses the current source group. Note: This property is only used if originId is used. If id is used the source of the id will take priority over the source |
Examples
"seoData": {
"type": "reference",
"originId": "{originId}",
"alias": "Seo",
"source": "anotherSourceGroupAlias"
}
"seoData": {
"type": "reference",
"id": "{id}",
"alias": "Seo"
}
"seoData": {
"type": "reference",
"id": "{id}",
"alias": "{p.seoAlias}"
}
The alias
can either be a static value, like "Seo" or it can be a dynamic value being resolved from the Source Entity that is being processed by Enterspeed. This allows for supporting almost any use case.
Reference response
The response of references differs in V1 and V2+ of the Delivery API. V1 return the id, type and wraps the properties from the referenced view in a view
property. The response of references in V2+ is much more clean and only return the actual properties from the referenced schema. If a reference is not found in V2+ the reference information are added in the missingViewReference
property in the meta
object for debug purpose.
{
// This example shows a response of a view with two schema references.
// image1 is referencing a found view with a url and name property
// and image2 is referencing a view that doesn't exist.
"meta": {
"missingViewReferences": []
},
"route": {
"image1": {
"id": "gid://Environment/8ef2bdc0-c352-4190-a344-c51d1f5e72ea/Source/dc5d9518-b96a-428a-a9b3-31fb601376c2/Entity/1234/View/image",
"view": {
"url": "https://test.com/how-to-write-a-good-blog-post.png",
"name": "How To Write A Good Blog Post"
},
"type": "ViewReference"
},
"image2": {
"id": "gid://Environment/8ef2bdc0-c352-4190-a344-c51d1f5e72ea/Source/dc5d9518-b96a-428a-a9b3-31fb601376c2/Entity/1235/View/image",
"view": null,
"type": "ViewReference"
}
}
}
{
// This example shows a response of a view with two schema references.
// image1 is referencing a found view with a url and name property
// and image2 is referencing a view that doesn't exist.
"meta": {
"missingViewReferences": [
{
"path": "image2",
"viewId": "gid://Environment/8ef2bdc0-c352-4190-a344-c51d1f5e72ea/Source/dc5d9518-b96a-428a-a9b3-31fb601376c2/Entity/1235/View/image"
}
]
},
"route": {
"image1": {
"url": "https://test.com/how-to-write-a-good-blog-post.png",
"name": "How To Write A Good Blog Post"
},
"image2": null
}
}
partial
Referencing a partial schema to map the data into.
The partial mapping property type allows for dynamically including partial schemas into the main schema. This is useful when you need to iterate an array of different objects that has an identifier, like an ID, alias or similar.
Partial schemas are typically used when you want a reusable schema for mapping data that is part of the same entity. Eg. meta data (title, description, ...) is the same across different entity types but the data lives on the entity it self.
Read more about partial schemas here
Fields
Property | Required? | Description |
---|---|---|
type | Yes | The property type - here partial |
input | Yes | Defines what goes into the partial schema |
alias | Yes | Is used to resolve what partial schema to use |
Examples
"blocks": {
"type": "array",
"input": "{p.contentBlocks}",
"items": {
"type": "partial",
"input": "{item}",
"alias": "Block-{item.contentType}"
}
}
The input
defines what goes into the partial schema and the alias
is used to resolve what partial schema to use. So in this case we could have partial schema with alias: Block-headline.
If you want to pass the entire current source entity to input, you can use {root}
.
dynamic
Fields
Property | Required? | Description |
---|---|---|
* | Yes | Path selector |
Examples
"blocks": {
"*": "p.contentBlocks"
}