(Redirected from Help:Schema)
Help:SchemaSchema types
Example of a constraint schema

The smw/schema namespace has been introduced12 to allow Semantic MediaWiki or related extensions to store different structured type definition (aka schema).

To create, edit, or modify a page in the smw/schema namespace, the smw-schemaedit user right is necessary.

  • Types contains details about available types and examples
  • Error handling explains how the JSON validation helps minimizes inconsistency and maintenance effort for a schema in the smw/schema namespace


The objective of the SMW_NS_SCHEMA (aka smw/schema) namespace is to allow for a structured definition of different schemata where types define the interpreter, syntax elements, and constraints.

The namespace expects a JSON format (or if available, YAML as superset of JSON) as input format to ensure that content elements are structured and a validation_schema (see JSON schema) may be assigned to a type to help enforce requirements and constraints for a specific type.

The following annotation properties are provided to make elements of a schema and its definition discoverable.

  • Schema type (_SCHEMA_TYPE )
  • Schema definition (_SCHEMA_DEF)
  • Schema description (_SCHEMA_DESC)
  • Schema tag (_SCHEMA_TAG)
  • Schema link (_SCHEMA_LINK)


Extensibility for new schema types and interpreters is provided by adding a new type to the $smwgSchemaTypes setting.

$GLOBALS['smwgSchemaTypes'] = [
    'FOO_SCHEMA' => [
        'group' => SMW_SCHEMA_FOO_GROUP,
        'validation_schema => __DIR__ . '/data/schema/foo-schema.v1.json',

In the example above, FOO_SCHEMA refers to the type name and any attributes assigned to that type will be used when constructing a schema instance. Types can define individual attributes that may be use exclusively by the type. - group defines types belonging to the same schemata class - validation_schema links to the JSON schema expected to be used

Available types

Technical notes

│   │
│   ├─ Schema
│   ├─ SchemaDefinition
│   ├─ SchemaFactory
│   └─ SchemaValidator
    └─ Content
        ├─ SchemaContent
        ├─ SchemaContentFormatter
        └─ SchemaContentHandler

See also[edit]


  1. ^  Semantic MediaWiki: GitHub pull request gh:smw:3019
  2. ^  Semantic MediaWiki: GitHub pull request gh:smw:3431