Schema

You can obtain the schema for a resource in the request parameter: ?format=json&schema=true. This way of requesting the schema is only available when requesting an Add form or when viewing a resource.

A specific URI is also available for obtaining the schema of a resource:

GET /api/(str:model_type)/(str:model_name)/schema/?format=json&hierarchy=pkid

The JSON schema uses the IETF draft-zyp-json-schema-03 (http://tools.ietf.org/html/draft-zyp-json-schema-03 and https://github.com/json-schema/json-schema)

The schema provides the properties of a field for each object in the schema describing the data of a resource:

  • $schema: The schema URI, currently http://json-schema.org/draft-03/schema.

  • title: This is the default field name.

  • required: The property and value true value is a property if the field is mandatory

  • type: The data type of the field. See the definitions and conventions in use. If the data type is:

    • object, then the object itself has a schema

    • array, then it has the property items

  • format: if the type is string, a further format of the string can be selected.

  • choices: In the case that the data element takes a value from a specified list of values.

  • target: where a resource is linked to another resource, this resource is indicated as the target.

  • target_attr: the specific attribute of the target.

  • attr_props: an object containing the list of properties of each attribute.

  • minItems: minimum number if the data type is an array.

  • maxItems: maximum number if the data type is an array.

  • items: the specified items if the data type is an array.

  • documentation and description: text content to document and describe the object.

  • name: name of the resource. [a-zA-Z_] characters are allowed

  • default: default value, if specified.

  • valid_re: the regular expression that a string data type should adhere to.

Example

Refer to the example data as in Data. The schema for the example data provides properties of each element:

schema: {
 $schema: "http://json-schema.org/draft-03/schema"
 type: "object"
 properties: {
 host: {
         required: true
         type: "string"
         title: "Host Name"
 }
 username: {
          required: true
          type: "string"
          title: "Admin Username"
 }
 password: {
          required: true
          type: "string"
          title: "Admin Password"
 }
 version: {
          target: "/api/data/CallManagerVersion/choices/
            ?hierarchy={hierarchy}&field=version&format=json"
          format: "uri"
          title: "Version"
          choices: [ ]
          target_attr: "version"
          type: "string"
 }
 port: {
          type: "string"
          title: "Port"
 }
 import: {
          type: "boolean"
          title: "Immediate Import"
 }
 data_sync: {
          target: "/api/data/DataSync/choices/
            ?hierarchy={hierarchy}&field=name&format=json"
          title: "Data Sync"
          format: "uri"
          choices: [ ]
          target_attr: "name"
          type: "string"
 }
 }
}