Specification

In TypeSchema our main specification is the TypeSchema meta schema which describes itself. This is a HTML representation which we automatically generate from this meta schema. There is also a TypeScript version of the specification.


TypeSchema

TypeSchema meta schema which describes a TypeSchema
{
  "title": String,
  "description": String,
  "type": String,
  "definitions": Definitions,
  "properties": Properties,
  "required": Array (String),
}
FieldDescription
titleString
descriptionString
typeString
Enum
  • "object"
definitionsDefinitions
Schema definitions which can be reused
propertiesProperties
Properties of a schema
requiredArray (String)
Array string values
MinItems
1

Definitions

Schema definitions which can be reused
{
  "*": ((CommonProperties & ContainerProperties & StructProperties) | (CommonProperties & ContainerProperties & MapProperties)) | (CommonProperties & ArrayProperties) | (CommonProperties & ScalarProperties & BooleanProperties) | (CommonProperties & ScalarProperties & NumberProperties) | (CommonProperties & ScalarProperties & StringProperties) | (AllOfProperties | OneOfProperties),
}
FieldDescription
*((CommonProperties & ContainerProperties & StructProperties) | (CommonProperties & ContainerProperties & MapProperties)) | (CommonProperties & ArrayProperties) | (CommonProperties & ScalarProperties & BooleanProperties) | (CommonProperties & ScalarProperties & NumberProperties) | (CommonProperties & ScalarProperties & StringProperties) | (AllOfProperties | OneOfProperties)
Schema definitions which can be reused

CommonProperties

Common properties which can be used at any schema
{
  "title": String,
  "description": String,
  "type": String,
  "nullable": Boolean,
  "deprecated": Boolean,
  "readonly": Boolean,
}
FieldDescription
titleString
Distinct word which represents this schema
descriptionString
General description of this schema, should not contain any new lines.
typeString
JSON type of the property
Enum
  • "object"
  • "array"
  • "boolean"
  • "integer"
  • "number"
  • "string"
nullableBoolean
Indicates whether it is possible to use a null value
deprecatedBoolean
Indicates whether this schema is deprecated
readonlyBoolean
Indicates whether this schema is readonly

ContainerProperties

Properties specific for a container
{
  "type": String,
}
FieldDescription
typeString
Enum
  • "object"

StructProperties

Struct specific properties
{
  "properties": Properties,
  "required": Array (String),
}
FieldDescription
propertiesProperties
Properties of a schema
requiredArray (String)
Array string values
MinItems
1

MapProperties

Map specific properties
{
  "additionalProperties": (CommonProperties & ScalarProperties & BooleanProperties) | (CommonProperties & ScalarProperties & NumberProperties) | (CommonProperties & ScalarProperties & StringProperties) | (CommonProperties & ArrayProperties) | (AllOfProperties | OneOfProperties) | ReferenceType,
  "maxProperties": Integer,
  "minProperties": Integer,
}
FieldDescription
additionalProperties(CommonProperties & ScalarProperties & BooleanProperties) | (CommonProperties & ScalarProperties & NumberProperties) | (CommonProperties & ScalarProperties & StringProperties) | (CommonProperties & ArrayProperties) | (AllOfProperties | OneOfProperties) | ReferenceType
Allowed values of an object property
maxPropertiesInteger
Positive integer value
minPropertiesInteger
Positive integer value

ArrayProperties

Array properties
{
  "type": String,
  "items": (CommonProperties & ScalarProperties & BooleanProperties) | (CommonProperties & ScalarProperties & NumberProperties) | (CommonProperties & ScalarProperties & StringProperties) | (AllOfProperties | OneOfProperties) | ReferenceType,
  "maxItems": Integer,
  "minItems": Integer,
  "uniqueItems": Boolean,
}
FieldDescription
typeString
Enum
  • "array"
items(CommonProperties & ScalarProperties & BooleanProperties) | (CommonProperties & ScalarProperties & NumberProperties) | (CommonProperties & ScalarProperties & StringProperties) | (AllOfProperties | OneOfProperties) | ReferenceType
Allowed values of an array item
maxItemsInteger
Positive integer value
minItemsInteger
Positive integer value
uniqueItemsBoolean

ScalarProperties

{
  "format": String,
  "enum": Array (String) | Array (Number),
  "default": String | Number | Boolean,
}
FieldDescription
formatString
Describes the specific format of this type i.e. date-time or int64
enumArray (String) | Array (Number)
A list of possible enumeration values
defaultString | Number | Boolean
Represents a scalar value

BooleanProperties

Boolean properties
{
  "type": String,
}
FieldDescription
typeString
Enum
  • "boolean"

NumberProperties

Number properties
{
  "type": String,
  "multipleOf": Number,
  "maximum": Number,
  "exclusiveMaximum": Boolean,
  "minimum": Number,
  "exclusiveMinimum": Boolean,
}
FieldDescription
typeString
Enum
  • "number"
  • "integer"
multipleOfNumber
maximumNumber
exclusiveMaximumBoolean
minimumNumber
exclusiveMinimumBoolean

StringProperties

String properties
{
  "type": String,
  "maxLength": Integer,
  "minLength": Integer,
  "pattern": String,
}
FieldDescription
typeString
Enum
  • "string"
maxLengthInteger
Positive integer value
minLengthInteger
Positive integer value
patternString

AllOfProperties

Combination keyword to represent an intersection type
{
  "description": String,
  "allOf": Array ((CommonProperties & ScalarProperties & NumberProperties) | (CommonProperties & ScalarProperties & StringProperties) | (CommonProperties & ScalarProperties & BooleanProperties) | ReferenceType),
}
FieldDescription
descriptionString
allOfArray ((CommonProperties & ScalarProperties & NumberProperties) | (CommonProperties & ScalarProperties & StringProperties) | (CommonProperties & ScalarProperties & BooleanProperties) | ReferenceType)
Combination values

OneOfProperties

Combination keyword to represent an union type
{
  "description": String,
  "discriminator": Discriminator,
  "oneOf": Array ((CommonProperties & ScalarProperties & NumberProperties) | (CommonProperties & ScalarProperties & StringProperties) | (CommonProperties & ScalarProperties & BooleanProperties) | ReferenceType),
}
FieldDescription
descriptionString
discriminatorDiscriminator
Adds support for polymorphism. The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description
oneOfArray ((CommonProperties & ScalarProperties & NumberProperties) | (CommonProperties & ScalarProperties & StringProperties) | (CommonProperties & ScalarProperties & BooleanProperties) | ReferenceType)
Combination values

Properties

Properties of a schema
{
  "*": (CommonProperties & ScalarProperties & BooleanProperties) | (CommonProperties & ScalarProperties & NumberProperties) | (CommonProperties & ScalarProperties & StringProperties) | (CommonProperties & ArrayProperties) | (AllOfProperties | OneOfProperties) | ReferenceType,
}
FieldDescription
*(CommonProperties & ScalarProperties & BooleanProperties) | (CommonProperties & ScalarProperties & NumberProperties) | (CommonProperties & ScalarProperties & StringProperties) | (CommonProperties & ArrayProperties) | (AllOfProperties | OneOfProperties) | ReferenceType
Properties of a schema

ReferenceType

Represents a reference to another schema
{
  "ref": String,
}
FieldDescription
refString
To disallow nesting we can reference only at the definitions layer
Pattern
^#/definitions/([A-Za-z0-9]+)$

Discriminator

Adds support for polymorphism. The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description
{
  "propertyName": String,
  "mapping": DiscriminatorMapping,
}
FieldDescription
propertyNameString
The name of the property in the payload that will hold the discriminator value
mappingDiscriminatorMapping
An object to hold mappings between payload values and schema names or references

DiscriminatorMapping

An object to hold mappings between payload values and schema names or references
{
  "*": String,
}
FieldDescription
*String
An object to hold mappings between payload values and schema names or references