Skip to main content

Dynamic Content- JSON Schema draft 7 support

Release date: 25th September 2019

In this release we've introduced support for the new keywords and string formats included in JSON Schema draft 7. You can now create content type schemas including constants, examples and comments as well as several new string formats. The Schema Editor and content editing form in the production view have been updated to support the new schema features.

On this page we'll provide you with an overview of the new keywords and string formats and provide links to pages with more information and examples.

If you create or edit a schema manually or use the Schema Editor and want to use the new keywords, you will need to edit the value of $schema to specify that you are using the updated schema vocabulary of JSON Schema draft 7. See the content type schema format page for more details.

Link copied!

The const keyword is used to specify the value of a property and indicate that it cannot be changed. You can use const with strings, numbers and other property types such as media links. For example, you could specify a set image that is always included with a content type, or some settings that cannot be changed.

You can add const properties using the Schema Editor by choosing "const" from the "Add Property" menu and choosing to add a text string or a number.

Adding a const in the Schema Editor

In the example shown below, the shippingcountry property is defined as a string with the value of "United Kingdom". This value cannot be changed by the user.

A const string shown in the schema preview window. The value cannot be edited by the user

As with the other new features, to use the const keyword, you must edit the schema to specify that you are using JSON Schema draft 7 vocabulary as explained above.

For more information about const and examples of its use see the introducing JSON Schema page.

New string formats
Link copied!

A number of new string formats are now supported including separate date and time, json-pointer and relative-json-pointer and regex. The Schema Editor has been updated to include these new formats in the list of suggestions shown when you type control-space when adding the format value to a string.

The Schema Editor has been updated to include suggestions for the new string formats

In the example below a string property is added with the format of date. The property is shown in the schema preview window.

A string property that uses the date format

Note that if you don't specify that your schema uses the JSON Schema draft 7 vocabulary, then if you add one of the new string formats the schema will not validate.

For more information about the new string formats see the strings page.

Examples and comments
Link copied!

The examples keyword allows developers to include an array of sample acceptable values for a property. These examples are then displayed in the content form in the production view as hints to the user.

In the content form, any properties with examples will be displayed with a "i" icon to the right of the property. Click this icon to display the examples in a pop up window.

The image below shows a string property which uses the date format. The content type schema includes examples for this property using the acceptable date format- full year, month and day.

Examples don't change the functionality or validation of a schema, but they do provide useful hints to the user.

The examples keyword allows a developer to provide sample values for a property. These are displayed in the content form in the production view.

The values included in the examples for a property are also used to populate the data shown in the "Sample output" window of the Schema Editor.

Sample JSON output populated from the examples for a property.

Comments can be added to a property or at the root level of a schema using the $comment keyword. They are not shown in the content editing form and do not affect the functionality of the schema. Comments are intended to provide notes to developers maintaining a schema.

For more details of the new keywords see the introducing JSON Schema page.