forked from voxpupuli/json-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for the provisional draft6 of json-schema
- Loading branch information
1 parent
56fe076
commit 89fd412
Showing
4 changed files
with
229 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require 'json-schema/schema/validator' | ||
|
||
module JSON | ||
class Schema | ||
|
||
class Draft6 < Validator | ||
def initialize | ||
super | ||
@attributes = { | ||
"type" => JSON::Schema::TypeV4Attribute, | ||
"allOf" => JSON::Schema::AllOfAttribute, | ||
"anyOf" => JSON::Schema::AnyOfAttribute, | ||
"oneOf" => JSON::Schema::OneOfAttribute, | ||
"not" => JSON::Schema::NotAttribute, | ||
"disallow" => JSON::Schema::DisallowAttribute, | ||
"format" => JSON::Schema::FormatAttribute, | ||
"maximum" => JSON::Schema::MaximumAttribute, | ||
"minimum" => JSON::Schema::MinimumAttribute, | ||
"minItems" => JSON::Schema::MinItemsAttribute, | ||
"maxItems" => JSON::Schema::MaxItemsAttribute, | ||
"minProperties" => JSON::Schema::MinPropertiesAttribute, | ||
"maxProperties" => JSON::Schema::MaxPropertiesAttribute, | ||
"uniqueItems" => JSON::Schema::UniqueItemsAttribute, | ||
"minLength" => JSON::Schema::MinLengthAttribute, | ||
"maxLength" => JSON::Schema::MaxLengthAttribute, | ||
"multipleOf" => JSON::Schema::MultipleOfAttribute, | ||
"enum" => JSON::Schema::EnumAttribute, | ||
"properties" => JSON::Schema::PropertiesV4Attribute, | ||
"required" => JSON::Schema::RequiredAttribute, | ||
"pattern" => JSON::Schema::PatternAttribute, | ||
"patternProperties" => JSON::Schema::PatternPropertiesAttribute, | ||
"additionalProperties" => JSON::Schema::AdditionalPropertiesAttribute, | ||
"items" => JSON::Schema::ItemsAttribute, | ||
"additionalItems" => JSON::Schema::AdditionalItemsAttribute, | ||
"dependencies" => JSON::Schema::DependenciesV4Attribute, | ||
"extends" => JSON::Schema::ExtendsAttribute, | ||
"$ref" => JSON::Schema::RefAttribute | ||
} | ||
@default_formats = { | ||
'date-time' => DateTimeV4Format, | ||
'ipv4' => IP4Format, | ||
'ipv6' => IP6Format, | ||
'uri' => UriFormat | ||
} | ||
@formats = @default_formats.clone | ||
@uri = JSON::Util::URI.parse("http://json-schema.org/draft-06/schema#") | ||
@names = ["draft6", "http://json-schema.org/draft-06/schema#"] | ||
@metaschema_name = "draft-06.json" | ||
end | ||
|
||
JSON::Validator.register_validator(self.new) | ||
JSON::Validator.register_default_validator(self.new) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module JSON | ||
class Schema | ||
|
||
class HyperDraft6 < Draft6 | ||
def initialize | ||
super | ||
@uri = JSON::Util::URI.parse("http://json-schema.org/draft-06/hyper-schema#") | ||
end | ||
|
||
JSON::Validator.register_validator(self.new) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
{ | ||
"id": "http://json-schema.org/draft-06/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"description": "Core schema meta-schema", | ||
"definitions": { | ||
"schemaArray": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": { "$ref": "#" } | ||
}, | ||
"positiveInteger": { | ||
"type": "integer", | ||
"minimum": 0 | ||
}, | ||
"positiveIntegerDefault0": { | ||
"allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ] | ||
}, | ||
"simpleTypes": { | ||
"enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ] | ||
}, | ||
"stringArray": { | ||
"type": "array", | ||
"items": { "type": "string" }, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
} | ||
}, | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"type": "string", | ||
"format": "uri" | ||
}, | ||
"$schema": { | ||
"type": "string", | ||
"format": "uri" | ||
}, | ||
"title": { | ||
"type": "string" | ||
}, | ||
"description": { | ||
"type": "string" | ||
}, | ||
"default": {}, | ||
"multipleOf": { | ||
"type": "number", | ||
"minimum": 0, | ||
"exclusiveMinimum": true | ||
}, | ||
"maximum": { | ||
"type": "number" | ||
}, | ||
"exclusiveMaximum": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"minimum": { | ||
"type": "number" | ||
}, | ||
"exclusiveMinimum": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"maxLength": { "$ref": "#/definitions/positiveInteger" }, | ||
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" }, | ||
"pattern": { | ||
"type": "string", | ||
"format": "regex" | ||
}, | ||
"additionalItems": { | ||
"anyOf": [ | ||
{ "type": "boolean" }, | ||
{ "$ref": "#" } | ||
], | ||
"default": {} | ||
}, | ||
"items": { | ||
"anyOf": [ | ||
{ "$ref": "#" }, | ||
{ "$ref": "#/definitions/schemaArray" } | ||
], | ||
"default": {} | ||
}, | ||
"maxItems": { "$ref": "#/definitions/positiveInteger" }, | ||
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" }, | ||
"uniqueItems": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"maxProperties": { "$ref": "#/definitions/positiveInteger" }, | ||
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" }, | ||
"required": { "$ref": "#/definitions/stringArray" }, | ||
"additionalProperties": { | ||
"anyOf": [ | ||
{ "type": "boolean" }, | ||
{ "$ref": "#" } | ||
], | ||
"default": {} | ||
}, | ||
"definitions": { | ||
"type": "object", | ||
"additionalProperties": { "$ref": "#" }, | ||
"default": {} | ||
}, | ||
"properties": { | ||
"type": "object", | ||
"additionalProperties": { "$ref": "#" }, | ||
"default": {} | ||
}, | ||
"patternProperties": { | ||
"type": "object", | ||
"additionalProperties": { "$ref": "#" }, | ||
"default": {} | ||
}, | ||
"dependencies": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"anyOf": [ | ||
{ "$ref": "#" }, | ||
{ "$ref": "#/definitions/stringArray" } | ||
] | ||
} | ||
}, | ||
"enum": { | ||
"type": "array", | ||
"minItems": 1, | ||
"uniqueItems": true | ||
}, | ||
"type": { | ||
"anyOf": [ | ||
{ "$ref": "#/definitions/simpleTypes" }, | ||
{ | ||
"type": "array", | ||
"items": { "$ref": "#/definitions/simpleTypes" }, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
} | ||
] | ||
}, | ||
"allOf": { "$ref": "#/definitions/schemaArray" }, | ||
"anyOf": { "$ref": "#/definitions/schemaArray" }, | ||
"oneOf": { "$ref": "#/definitions/schemaArray" }, | ||
"not": { "$ref": "#" } | ||
}, | ||
"dependencies": { | ||
"exclusiveMaximum": [ "maximum" ], | ||
"exclusiveMinimum": [ "minimum" ] | ||
}, | ||
"default": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters