The schema editor
The schema editor makes it easier to create and edit content type schemas. Schemas can still be created and stored externally to Dynamic Content in AWS, GitHub or whatever hosting service you choose, but the editor allows you to create, edit and manage schemas within your Dynamic Content hub. The schema editor includes snippets for most common property types, validates your syntax as you type and includes a preview feature that lets you see how content created using a schema will look in the content editing window. You can also use the editor for creating slot type schemas, as well as managing partials, or common definitions that can be used in many different schemas.
On this page we'll provide an overview of the features of the schema editor using the example of a simple text block.
There are several other examples in this section:
Using partials shows how to use the schema editor to create a partial- a schema with just a definitions section- and include these definitions in other schemas. It also shows how to include and refer to a definitions section within the same content type schema.
On this page
- Create a content type schema and give it a unique URL. The URL just needs to be valid to ensure that the schema is valid JSON schema format. The URL will not be resolved and we do not enforce any naming standards
- Choose the validation to be used by the schema editor. For a content type schema choose "content type". You can also create slot schemas and partials
- Save the schema and open the schema editing window
- Add the properties you require. The schema editor provides shortcuts for most property types. You can preview how content created from this schema will appear in the content editing form
- Save the schema. The schema editor will only allow you to the save the schema if it is valid
- Register a content type from the schema. To create a content type you specify the schema URL, label and optionally an icon, card and visualizations. You also select which repositories the content type is associated with.
- The content type is now available for the user to create content.
The following example takes you through these steps in more detail.
Creating a content type schema
To create or edit a content type schema, choose "Content type schemas" from the development menu in the Dynamic Content app. If the Development menu is not shown, contact your Custom Success Manager to ensure that you have the required permissions.
The content type schemas screen will be shown. From here you can view existing schemas or create a new one. To create a new schema click the "Create schema" button as shown in the image below.
Give the schema a unique ID. To ensure that it is a valid JSON Schema, the schema ID must be a valid URL. The URL will never be resolved, so it can be anything you like. In this example we're using http://example.com/simpletextblock.json and you may wish to use your own domain as a way of organizing your schema types, but we don't enforce any standard.
Choose the type of schema you wish to create: content type, slot or partial. The schema editor will validate the schema based on what it's being used for. Slots can only contain certain property types, while partials refer to schemas containing definitions that can be shared and reused between multiple schemas and will just contain a "definitions" section. In this case we're creating a content type.
You can choose "Save" to save the schema and return to the content type schema window or "Save and open schema" to save and open the schema for editing.
From the content type schema window you can double-click a schema to open it for editing or choose "Open" from its contextual menu.
The schema editor opens with a outline of the schema already filled in. All you need to do is add the properties you require.
The editor has type ahead features that will attempt to fill in properties as you type or you can choose the properties you want to add from the "Add property" menu. From here you can choose simple properties such as strings, rich text and numbers as well as chooser properties: content links and content references, image and video types. We also support arrays and localized properties. For the simple text block we'll choose a text property.
The text property is added with default values for the property name, title and description, as well as the validation. Change these values to whatever you want, ensuring the property name is unique within the schema. In this example we want to allow the user to enter a string of up to 200 characters, so we'll change the maxLength to 200.
The content form preview
You can show a preview of how a content type registered from this schema will look in the content editing window by clicking the "preview" icon as highlighted below.
The preview also applies any validation that you have defined for a property, so in this case the text is limited to 200 characters.
Adding array properties
The add property menu also provides some shortcuts for adding lists. In the text block example we want to add an array of paragraphs, so we choose "List of text" from the menu. You can also choose images, content links or enums- which are represented in JSON Schema as enums.
An outline of the array property is added to the schema window. For this example the maximum number of items will be set to 4. Notice that the preview shows the array as it will appear in the content editing window, allowing up to 4 array items to be added.
When you've added all the properties you want in your content type schema, click the "Save" button to save it. If any validation errors are shown in the schema editor window, you'll need to correct these before the schema can be saved.
Previewing JSON output
You can view sample JSON data generated from the current schema by choosing the "Sample JSON Output" tab. The generated JSON includes sample values for all property types including strings, images, video and any localized properties. This feature helps save you time when creating your rendering code and templates by giving you example JSON output to work with.
You can configure the format of the generated JSON from the settings dialog. The "Show optional properties" setting allows you to control how optional properties, those not defined as required in your schema, are included in the JSON output. If you choose "some", then the optional properties will be chosen randomly, while if you choose "none", only the required properties will be included.
Sample names can also be included to be used for images and video, so you can include example asset names from your Content Hub account.
You can also choose the output format: either "SDK" format, which represents content as a content tree, or JSON linked data (JSON-LD). In most cases you will work with content in SDK format. See the Content Delivery API and Content Delivery SDK pages for more details.
In the image below we have chosen to display some of the optional properties. The properties displayed will be chosen at random and have random property lengths. If you choose to include all optional properties then the properties are generated to use the maximum length of each property.
Registering a content type
In order for the content type schema to be used, you first have to use it to register a content type. A content type consists of the schema URL, together with a label and optionally an icon, card and one or more visualizations. Content types are what are what the users will use to create content in the production view of the Dynamic Content app.
To register a content type, choose "Content types" from the development menu. A list of the content types that are already registered will be displayed. To register a new content type click the "Register content type" button as shown in the image below.
The register content type screen is opened. The first thing you need to enter is the URL of the content type schema. As we mentioned earlier, content type schemas can either be created using the schema editor and stored internally or stored on an external hosting service. In this example we want to register the text block as a content type so we'll choose "internal". Click underneath the "Pick a schema" text and choose which schema to use. Once a content type is registered, you can update its label, icon, card and visualization, but the URL cannot be changed.
For the text block we'll give it a label of "Simple text block" and enable it on the repository named "content". See registering content types for more details about associating content types with repositories and adding icons, cards and visualizations.
When you've filled in all the fields you require, click the "Save" button. The content type is now registered with the hub and available to use to create content in the repositories you associated it with.
In the production view choose "Create content". The simple text block is shown and you can use this to create content.
The content editing window opens and the user can fill in the fields and save the content.
Editing a schema
You can edit a schema by double-clicking it in the schema list or choosing "Open" from its contextual menu. In the text block example we want to edit the "propertyOrder" property to ensure that the properties are shown in the correct order in the content editing form. When you make a change to a schema, make the change and click "Save". If the schema is still valid, your change will be applied.
If you make a change to the schema and you've already used it to register a content type then you need to "sync" the content type with the schema to ensure that the content type uses the latest version.
To update the text block, choose "Sync with schema" from its menu in the content types window.
When the user views or edits content of this type in the production view, the properties are now shown in the correct order.
Note that changing the order of properties in a content type schema will not effect any content already created, but care should be taken when updating a schema. See Syncing a content type with its schema for more information.
You can view a schema's version history and restore to a previous version. To view the version history for a schema, click the clock icon at the top of the schema window. A list of available versions will be displayed, including information about when a change was made and who made it.
In the example shown below, a property called "categorytext" has been added to the schema and then the schema has been saved. A new version, version 11 has been created.
You can select a previous version to view it in read only mode in the schema window. In the example shown below, version 8 of the schema is selected, a version that doesn't include the "categorytext" property. To restore to a selected previous version, click "Restore this version".
When the schema is restored from a previous version, a new version is created. In this example, a new version, version 12 is created, restored from version 8 of the schema.
If a content type has already been registered from this schema, you will need to sync the content type with the schema to ensure it is using the latest version. See Syncing a content type with its schema for more information.
Video: Creating and registering a content type schema
Using the example of a simple banner, this video shows you how to create a content type schema with the Schema Editor, how to register the schema as a content type and how this content type is used to create content.