Property types

Properties must be one of the following types. These are standard types defined in the JSON Schema specification:

Type Description
string A string of text that may contain unicode characters
number Any numeric type. It can be an integer or floating point number
integer An integral number
boolean A value that can be true or false
object A JSON object. Can be defined inline or via a $ref to an internal or external type
array A JSON array containing ordered elements. Typically used in nested content types to stored linked content items. See the Carousel sample for an example of its use.

Note that the null data type is not supported.

Each property can include a title and description.

Examples

The snippets below show examples of each property together with images to show how properties of this type appear in the content editing user interface.

String types are described in detail on the strings page.

Number

In the example below, the bannerOpacity property is defined as a number. The minimum and maximum keywords are used as additional validation to ensure that the number entered is between 0 and 1.

"properties": { "bannerOpacity": { "title": "opacity", "description": "A value between 0 and 1 (e.g. 0.3)", "type": "number", "minimum": 0, "maximum": 1 } }


Expand the images below to see the number property as it is displayed in the content editing form.

A valid number property
A valid number property

The content editing UI enforces the validation defined for this property. So if the user attempts to add a value greater than 1.01, a warning is displayed and the content cannot be saved until they correct the error.

A number property with a validation error
A number property with a validation error
Integer

The integer type is an integral value. In the snippet below there is no maximum set, but it doesn't make any sense for a stock value to fall below 0.

"properties": { "stockLevel": { "title": "stock level", "description": "The stock level for this item", "type": "integer", "minimum": 0 } }


Boolean

The boolean type is a simple true or false. In the example below, the user will choose whether to select an option for the way a banner is displayed on mobile screen sizes.

"properties": { "stackMobileLayout": { "title": "Stack mobile layout", "description": "Enable to allow banner text to stack underneath the image on small screens", "type": "boolean" } }


Array

The array property is often used to hold a list of external objects, such as in the carousel example where the slides property contains the carousel slide items. The maxItems validation keyword is used to set the maximum number of items, in this case carousel slides, that can be added to 6.

"properties": { "slides": { "type": "array", "items": { "allOf": [ { "$ref": "http://bigcontent.io/cms/schema/v1/core#/definitions/content-link" }, { "properties": { "contentType": { "title": "Carousel Slides", "enum": [ "https://s3-eu-west-1.amazonaws.com/amp-product/tutorials/dynamiccontenttutorials/carouselslide.json" ] } } } ], "minItems": 1, "maxItems": 6, "title": "Carousel Slides", "description": "" } } }

Arrays are also useful for simple types, such as shown in the following example:

"properties": { "primitiveList": { "type": "array", "items": { "description": "Primitive list item description", "type": "string", "title": "Primitive list item" } } }
Object

The object type is used as the root object for all content types and also to define inline content or an external type via a chooser. For more details see the choosers and Inline content pages.

results matching ""

    No results matching ""