Composite schemas allow you to reuse schemas in other schemas.

Introduction

A convenient way to create custom schemas is to build definitions that can be reused in multiple entity schemas. These definitions can be included into an entity schema with a mixin.

 For example, the  asset-schema.json contains basic definitions to be used in any other entity schema:

{
    "cs:asset.type" : null,
    "type" : "object",
    "properties" : {
        "name" : {
        	"type" : "string",
            "cs:feature.key" : "censhare:asset.name"
        },
        "id" : {
        	"type" : "number",
            "cs:feature.key" : "censhare:asset.id"
        }
    }
}
Remarks

(1) The cs:asset.type must be null. This is required if the schema is included in another entity schema via mixin.

(2) The name and id are asset attributes that are present in any censhare asset. Therefore, these attributes can be included in any entity schema.

To include the above definition in an entity schema, a mixin must be added that references the JSON file:

{
    "cs:$mixin": [
        "asset-schema.json"
    ],
    "cs:asset.type": "text.",
    "type": "object",
    "properties": {
        "content": {
            "cs:storage.item": "master",
            "type": "string"
        }
    }
}

Cascaded mixins

You can also use casceded mixins. Proceed as follows:

  1. In a base-schema.json, map the attributes that are present in all your entity types.
  2. In a group-1-schema.json, map the attributes that are only present in a certain group of entities.
  3. Include the base-schema.json in the  group-1-schema.json  via mixin.
  4. Define the entity schemas for all asset types of group 1.
  5. Include the group-1-schema.json in all entity schemas that belong to group 1 via mixin.

This also includes the base-schema.json defintion as part of the group-1-schema.json in the entity schemas.