codecombat/app/schemas/metaschema.coffee

133 lines
3.4 KiB
CoffeeScript
Raw Normal View History

2014-04-12 14:05:56 +05:30
# The JSON Schema Core/Validation Meta-Schema, but with titles and descriptions added to make it easier to edit in Treema, and in CoffeeScript
module.exports =
2014-07-01 10:16:26 +08:00
id: 'metaschema'
displayProperty: 'title'
$schema: 'http://json-schema.org/draft-04/schema#'
title: 'Schema'
description: 'Core schema meta-schema'
2014-04-12 14:05:56 +05:30
definitions:
schemaArray:
2014-07-01 10:16:26 +08:00
type: 'array'
2014-04-12 14:05:56 +05:30
minItems: 1
2014-07-01 10:16:26 +08:00
items: {$ref: '#'}
title: 'Array of Schemas'
'default': [{}]
2014-04-12 14:05:56 +05:30
positiveInteger:
2014-07-01 10:16:26 +08:00
type: 'integer'
2014-04-12 14:05:56 +05:30
minimum: 0
2014-07-01 10:16:26 +08:00
title: 'Positive Integer'
2014-04-12 14:05:56 +05:30
positiveIntegerDefault0:
2014-07-01 10:16:26 +08:00
allOf: [{$ref: '#/definitions/positiveInteger'}, {'default': 0}]
2014-04-12 14:05:56 +05:30
simpleTypes:
2014-07-01 10:16:26 +08:00
title: 'Single Type'
'enum': ['array', 'boolean', 'integer', 'null', 'number', 'object', 'string']
2014-04-12 14:05:56 +05:30
stringArray:
2014-07-01 10:16:26 +08:00
type: 'array'
items: {type: 'string'}
2014-04-12 14:05:56 +05:30
minItems: 1
uniqueItems: true
2014-07-01 10:16:26 +08:00
title: 'String Array'
'default': ['']
type: 'object'
2014-04-12 14:05:56 +05:30
properties:
id:
2014-07-01 10:16:26 +08:00
type: 'string'
format: 'uri'
2014-04-12 14:05:56 +05:30
$schema:
2014-07-01 10:16:26 +08:00
type: 'string'
format: 'uri'
'default': 'http://json-schema.org/draft-04/schema#'
2014-04-12 14:05:56 +05:30
title:
2014-07-01 10:16:26 +08:00
type: 'string'
2014-04-12 14:05:56 +05:30
description:
2014-07-01 10:16:26 +08:00
type: 'string'
'default': {}
2014-04-12 14:05:56 +05:30
multipleOf:
2014-07-01 10:16:26 +08:00
type: 'number'
2014-04-12 14:05:56 +05:30
minimum: 0
exclusiveMinimum: true
maximum:
2014-07-01 10:16:26 +08:00
type: 'number'
2014-04-12 14:05:56 +05:30
exclusiveMaximum:
2014-07-01 10:16:26 +08:00
type: 'boolean'
'default': false
2014-04-12 14:05:56 +05:30
minimum:
2014-07-01 10:16:26 +08:00
type: 'number'
2014-04-12 14:05:56 +05:30
exclusiveMinimum:
2014-07-01 10:16:26 +08:00
type: 'boolean'
'default': false
maxLength: {$ref: '#/definitions/positiveInteger'}
minLength: {$ref: '#/definitions/positiveIntegerDefault0'}
2014-04-12 14:05:56 +05:30
pattern:
2014-07-01 10:16:26 +08:00
type: 'string'
format: 'regex'
2014-04-12 14:05:56 +05:30
additionalItems:
anyOf: [
2014-07-01 10:16:26 +08:00
{type: 'boolean', 'default': false}
{$ref: '#'}
2014-04-12 14:05:56 +05:30
]
items:
anyOf: [
2014-07-01 10:16:26 +08:00
{$ref: '#'}
{$ref: '#/definitions/schemaArray'}
2014-04-12 14:05:56 +05:30
]
2014-07-01 10:16:26 +08:00
'default': {}
maxItems: {$ref: '#/definitions/positiveInteger'}
minItems: {$ref: '#/definitions/positiveIntegerDefault0'}
2014-04-12 14:05:56 +05:30
uniqueItems:
2014-07-01 10:16:26 +08:00
type: 'boolean'
'default': false
maxProperties: {$ref: '#/definitions/positiveInteger'}
minProperties: {$ref: '#/definitions/positiveIntegerDefault0'}
required: {$ref: '#/definitions/stringArray'}
2014-04-12 14:05:56 +05:30
additionalProperties:
anyOf: [
2014-07-01 10:16:26 +08:00
{type: 'boolean', 'default': true}
{$ref: '#'}
2014-04-12 14:05:56 +05:30
]
2014-07-01 10:16:26 +08:00
'default': {}
2014-04-12 14:05:56 +05:30
definitions:
2014-07-01 10:16:26 +08:00
type: 'object'
additionalProperties: {$ref: '#'}
'default': {}
2014-04-12 14:05:56 +05:30
properties:
2014-07-01 10:16:26 +08:00
type: 'object'
additionalProperties: {$ref: '#'}
'default': {}
2014-04-12 14:05:56 +05:30
patternProperties:
2014-07-01 10:16:26 +08:00
type: 'object'
additionalProperties: {$ref: '#'}
'default': {}
2014-04-12 14:05:56 +05:30
dependencies:
2014-07-01 10:16:26 +08:00
type: 'object'
2014-04-12 14:05:56 +05:30
additionalProperties:
anyOf: [
2014-07-01 10:16:26 +08:00
{$ref: '#'}
{$ref: '#/definitions/stringArray'}
2014-04-12 14:05:56 +05:30
]
2014-07-01 10:16:26 +08:00
'enum':
type: 'array'
2014-04-12 14:05:56 +05:30
minItems: 1
uniqueItems: true
2014-07-01 10:16:26 +08:00
'default': ['']
2014-04-12 14:05:56 +05:30
type:
anyOf: [
2014-07-01 10:16:26 +08:00
{$ref: '#/definitions/simpleTypes'}
2014-04-12 14:05:56 +05:30
{
2014-07-01 10:16:26 +08:00
type: 'array'
items: {$ref: '#/definitions/simpleTypes'}
2014-04-12 14:05:56 +05:30
minItems: 1
uniqueItems: true
2014-07-01 10:16:26 +08:00
title: 'Array of Types'
'default': ['string']
2014-04-12 14:05:56 +05:30
}]
2014-07-01 10:16:26 +08:00
allOf: {$ref: '#/definitions/schemaArray'}
anyOf: {$ref: '#/definitions/schemaArray'}
oneOf: {$ref: '#/definitions/schemaArray'}
not: {$ref: '#'}
2014-04-12 14:05:56 +05:30
dependencies:
2014-07-01 10:16:26 +08:00
exclusiveMaximum: ['maximum']
exclusiveMinimum: ['minimum']
'default': {}