json-schema 2.8.0 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +82 -11
  3. data/lib/json-schema/attribute.rb +13 -14
  4. data/lib/json-schema/attributes/additionalitems.rb +1 -0
  5. data/lib/json-schema/attributes/additionalproperties.rb +3 -6
  6. data/lib/json-schema/attributes/allof.rb +6 -4
  7. data/lib/json-schema/attributes/anyof.rb +2 -2
  8. data/lib/json-schema/attributes/const.rb +15 -0
  9. data/lib/json-schema/attributes/dependencies.rb +1 -6
  10. data/lib/json-schema/attributes/dependencies_v4.rb +11 -0
  11. data/lib/json-schema/attributes/disallow.rb +2 -1
  12. data/lib/json-schema/attributes/divisibleby.rb +1 -1
  13. data/lib/json-schema/attributes/enum.rb +2 -2
  14. data/lib/json-schema/attributes/extends.rb +7 -7
  15. data/lib/json-schema/attributes/format.rb +2 -1
  16. data/lib/json-schema/attributes/formats/custom.rb +1 -1
  17. data/lib/json-schema/attributes/formats/date.rb +2 -1
  18. data/lib/json-schema/attributes/formats/date_time.rb +3 -2
  19. data/lib/json-schema/attributes/formats/date_time_v4.rb +2 -1
  20. data/lib/json-schema/attributes/formats/ip.rb +1 -1
  21. data/lib/json-schema/attributes/formats/time.rb +1 -1
  22. data/lib/json-schema/attributes/formats/uri.rb +2 -1
  23. data/lib/json-schema/attributes/items.rb +1 -0
  24. data/lib/json-schema/attributes/limit.rb +0 -127
  25. data/lib/json-schema/attributes/limits/items.rb +15 -0
  26. data/lib/json-schema/attributes/limits/length.rb +15 -0
  27. data/lib/json-schema/attributes/limits/max_items.rb +15 -0
  28. data/lib/json-schema/attributes/limits/max_length.rb +15 -0
  29. data/lib/json-schema/attributes/limits/max_properties.rb +15 -0
  30. data/lib/json-schema/attributes/limits/maximum.rb +15 -0
  31. data/lib/json-schema/attributes/limits/maximum_inclusive.rb +11 -0
  32. data/lib/json-schema/attributes/limits/min_items.rb +15 -0
  33. data/lib/json-schema/attributes/limits/min_length.rb +15 -0
  34. data/lib/json-schema/attributes/limits/min_properties.rb +15 -0
  35. data/lib/json-schema/attributes/limits/minimum.rb +15 -0
  36. data/lib/json-schema/attributes/limits/minimum_inclusive.rb +11 -0
  37. data/lib/json-schema/attributes/limits/numeric.rb +16 -0
  38. data/lib/json-schema/attributes/limits/properties.rb +15 -0
  39. data/lib/json-schema/attributes/maxdecimal.rb +1 -1
  40. data/lib/json-schema/attributes/not.rb +2 -2
  41. data/lib/json-schema/attributes/oneof.rb +2 -4
  42. data/lib/json-schema/attributes/patternproperties.rb +2 -1
  43. data/lib/json-schema/attributes/properties.rb +9 -17
  44. data/lib/json-schema/attributes/properties_v4.rb +13 -0
  45. data/lib/json-schema/attributes/propertynames.rb +23 -0
  46. data/lib/json-schema/attributes/ref.rb +8 -8
  47. data/lib/json-schema/attributes/required.rb +4 -3
  48. data/lib/json-schema/attributes/type.rb +3 -2
  49. data/lib/json-schema/attributes/type_v4.rb +1 -1
  50. data/lib/json-schema/errors/validation_error.rb +5 -6
  51. data/lib/json-schema/schema/reader.rb +3 -1
  52. data/lib/json-schema/schema/validator.rb +3 -3
  53. data/lib/json-schema/schema.rb +3 -4
  54. data/lib/json-schema/util/array_set.rb +1 -1
  55. data/lib/json-schema/util/uri.rb +98 -75
  56. data/lib/json-schema/util/uuid.rb +203 -226
  57. data/lib/json-schema/validator.rb +122 -115
  58. data/lib/json-schema/validators/draft1.rb +21 -23
  59. data/lib/json-schema/validators/draft2.rb +22 -24
  60. data/lib/json-schema/validators/draft3.rb +26 -28
  61. data/lib/json-schema/validators/draft4.rb +34 -36
  62. data/lib/json-schema/validators/draft6.rb +36 -36
  63. data/lib/json-schema/validators/hyper-draft1.rb +2 -3
  64. data/lib/json-schema/validators/hyper-draft2.rb +2 -3
  65. data/lib/json-schema/validators/hyper-draft3.rb +2 -3
  66. data/lib/json-schema/validators/hyper-draft4.rb +2 -3
  67. data/lib/json-schema/validators/hyper-draft6.rb +2 -3
  68. data/lib/json-schema.rb +2 -3
  69. data/resources/draft-06.json +41 -41
  70. metadata +67 -31
@@ -2,28 +2,27 @@ require 'json-schema/schema/validator'
2
2
 
3
3
  module JSON
4
4
  class Schema
5
-
6
5
  class Draft2 < Validator
7
6
  def initialize
8
7
  super
9
8
  @attributes = {
10
- "type" => JSON::Schema::TypeAttribute,
11
- "disallow" => JSON::Schema::DisallowAttribute,
12
- "format" => JSON::Schema::FormatAttribute,
13
- "maximum" => JSON::Schema::MaximumInclusiveAttribute,
14
- "minimum" => JSON::Schema::MinimumInclusiveAttribute,
15
- "minItems" => JSON::Schema::MinItemsAttribute,
16
- "maxItems" => JSON::Schema::MaxItemsAttribute,
17
- "uniqueItems" => JSON::Schema::UniqueItemsAttribute,
18
- "minLength" => JSON::Schema::MinLengthAttribute,
19
- "maxLength" => JSON::Schema::MaxLengthAttribute,
20
- "divisibleBy" => JSON::Schema::DivisibleByAttribute,
21
- "enum" => JSON::Schema::EnumAttribute,
22
- "properties" => JSON::Schema::PropertiesOptionalAttribute,
23
- "pattern" => JSON::Schema::PatternAttribute,
24
- "additionalProperties" => JSON::Schema::AdditionalPropertiesAttribute,
25
- "items" => JSON::Schema::ItemsAttribute,
26
- "extends" => JSON::Schema::ExtendsAttribute
9
+ 'type' => JSON::Schema::TypeAttribute,
10
+ 'disallow' => JSON::Schema::DisallowAttribute,
11
+ 'format' => JSON::Schema::FormatAttribute,
12
+ 'maximum' => JSON::Schema::MaximumInclusiveAttribute,
13
+ 'minimum' => JSON::Schema::MinimumInclusiveAttribute,
14
+ 'minItems' => JSON::Schema::MinItemsAttribute,
15
+ 'maxItems' => JSON::Schema::MaxItemsAttribute,
16
+ 'uniqueItems' => JSON::Schema::UniqueItemsAttribute,
17
+ 'minLength' => JSON::Schema::MinLengthAttribute,
18
+ 'maxLength' => JSON::Schema::MaxLengthAttribute,
19
+ 'divisibleBy' => JSON::Schema::DivisibleByAttribute,
20
+ 'enum' => JSON::Schema::EnumAttribute,
21
+ 'properties' => JSON::Schema::PropertiesOptionalAttribute,
22
+ 'pattern' => JSON::Schema::PatternAttribute,
23
+ 'additionalProperties' => JSON::Schema::AdditionalPropertiesAttribute,
24
+ 'items' => JSON::Schema::ItemsAttribute,
25
+ 'extends' => JSON::Schema::ExtendsAttribute,
27
26
  }
28
27
  @default_formats = {
29
28
  'date-time' => DateTimeFormat,
@@ -31,16 +30,15 @@ module JSON
31
30
  'time' => TimeFormat,
32
31
  'ip-address' => IP4Format,
33
32
  'ipv6' => IP6Format,
34
- 'uri' => UriFormat
33
+ 'uri' => UriFormat,
35
34
  }
36
35
  @formats = @default_formats.clone
37
- @uri = JSON::Util::URI.parse("http://json-schema.org/draft-02/schema#")
38
- @names = ["draft2"]
39
- @metaschema_name = "draft-02.json"
36
+ @uri = JSON::Util::URI.parse('http://json-schema.org/draft-02/schema#')
37
+ @names = ['draft2']
38
+ @metaschema_name = 'draft-02.json'
40
39
  end
41
40
 
42
- JSON::Validator.register_validator(self.new)
41
+ JSON::Validator.register_validator(new)
43
42
  end
44
-
45
43
  end
46
44
  end
@@ -2,32 +2,31 @@ require 'json-schema/schema/validator'
2
2
 
3
3
  module JSON
4
4
  class Schema
5
-
6
5
  class Draft3 < Validator
7
6
  def initialize
8
7
  super
9
8
  @attributes = {
10
- "type" => JSON::Schema::TypeAttribute,
11
- "disallow" => JSON::Schema::DisallowAttribute,
12
- "format" => JSON::Schema::FormatAttribute,
13
- "maximum" => JSON::Schema::MaximumAttribute,
14
- "minimum" => JSON::Schema::MinimumAttribute,
15
- "minItems" => JSON::Schema::MinItemsAttribute,
16
- "maxItems" => JSON::Schema::MaxItemsAttribute,
17
- "uniqueItems" => JSON::Schema::UniqueItemsAttribute,
18
- "minLength" => JSON::Schema::MinLengthAttribute,
19
- "maxLength" => JSON::Schema::MaxLengthAttribute,
20
- "divisibleBy" => JSON::Schema::DivisibleByAttribute,
21
- "enum" => JSON::Schema::EnumAttribute,
22
- "properties" => JSON::Schema::PropertiesAttribute,
23
- "pattern" => JSON::Schema::PatternAttribute,
24
- "patternProperties" => JSON::Schema::PatternPropertiesAttribute,
25
- "additionalProperties" => JSON::Schema::AdditionalPropertiesAttribute,
26
- "items" => JSON::Schema::ItemsAttribute,
27
- "additionalItems" => JSON::Schema::AdditionalItemsAttribute,
28
- "dependencies" => JSON::Schema::DependenciesAttribute,
29
- "extends" => JSON::Schema::ExtendsAttribute,
30
- "$ref" => JSON::Schema::RefAttribute
9
+ 'type' => JSON::Schema::TypeAttribute,
10
+ 'disallow' => JSON::Schema::DisallowAttribute,
11
+ 'format' => JSON::Schema::FormatAttribute,
12
+ 'maximum' => JSON::Schema::MaximumAttribute,
13
+ 'minimum' => JSON::Schema::MinimumAttribute,
14
+ 'minItems' => JSON::Schema::MinItemsAttribute,
15
+ 'maxItems' => JSON::Schema::MaxItemsAttribute,
16
+ 'uniqueItems' => JSON::Schema::UniqueItemsAttribute,
17
+ 'minLength' => JSON::Schema::MinLengthAttribute,
18
+ 'maxLength' => JSON::Schema::MaxLengthAttribute,
19
+ 'divisibleBy' => JSON::Schema::DivisibleByAttribute,
20
+ 'enum' => JSON::Schema::EnumAttribute,
21
+ 'properties' => JSON::Schema::PropertiesAttribute,
22
+ 'pattern' => JSON::Schema::PatternAttribute,
23
+ 'patternProperties' => JSON::Schema::PatternPropertiesAttribute,
24
+ 'additionalProperties' => JSON::Schema::AdditionalPropertiesAttribute,
25
+ 'items' => JSON::Schema::ItemsAttribute,
26
+ 'additionalItems' => JSON::Schema::AdditionalItemsAttribute,
27
+ 'dependencies' => JSON::Schema::DependenciesAttribute,
28
+ 'extends' => JSON::Schema::ExtendsAttribute,
29
+ '$ref' => JSON::Schema::RefAttribute,
31
30
  }
32
31
  @default_formats = {
33
32
  'date-time' => DateTimeFormat,
@@ -35,16 +34,15 @@ module JSON
35
34
  'ip-address' => IP4Format,
36
35
  'ipv6' => IP6Format,
37
36
  'time' => TimeFormat,
38
- 'uri' => UriFormat
37
+ 'uri' => UriFormat,
39
38
  }
40
39
  @formats = @default_formats.clone
41
- @uri = JSON::Util::URI.parse("http://json-schema.org/draft-03/schema#")
42
- @names = ["draft3", "http://json-schema.org/draft-03/schema#"]
43
- @metaschema_name = "draft-03.json"
40
+ @uri = JSON::Util::URI.parse('http://json-schema.org/draft-03/schema#')
41
+ @names = ['draft3', 'http://json-schema.org/draft-03/schema#']
42
+ @metaschema_name = 'draft-03.json'
44
43
  end
45
44
 
46
- JSON::Validator.register_validator(self.new)
45
+ JSON::Validator.register_validator(new)
47
46
  end
48
-
49
47
  end
50
48
  end
@@ -2,55 +2,53 @@ require 'json-schema/schema/validator'
2
2
 
3
3
  module JSON
4
4
  class Schema
5
-
6
5
  class Draft4 < Validator
7
6
  def initialize
8
7
  super
9
8
  @attributes = {
10
- "type" => JSON::Schema::TypeV4Attribute,
11
- "allOf" => JSON::Schema::AllOfAttribute,
12
- "anyOf" => JSON::Schema::AnyOfAttribute,
13
- "oneOf" => JSON::Schema::OneOfAttribute,
14
- "not" => JSON::Schema::NotAttribute,
15
- "disallow" => JSON::Schema::DisallowAttribute,
16
- "format" => JSON::Schema::FormatAttribute,
17
- "maximum" => JSON::Schema::MaximumAttribute,
18
- "minimum" => JSON::Schema::MinimumAttribute,
19
- "minItems" => JSON::Schema::MinItemsAttribute,
20
- "maxItems" => JSON::Schema::MaxItemsAttribute,
21
- "minProperties" => JSON::Schema::MinPropertiesAttribute,
22
- "maxProperties" => JSON::Schema::MaxPropertiesAttribute,
23
- "uniqueItems" => JSON::Schema::UniqueItemsAttribute,
24
- "minLength" => JSON::Schema::MinLengthAttribute,
25
- "maxLength" => JSON::Schema::MaxLengthAttribute,
26
- "multipleOf" => JSON::Schema::MultipleOfAttribute,
27
- "enum" => JSON::Schema::EnumAttribute,
28
- "properties" => JSON::Schema::PropertiesV4Attribute,
29
- "required" => JSON::Schema::RequiredAttribute,
30
- "pattern" => JSON::Schema::PatternAttribute,
31
- "patternProperties" => JSON::Schema::PatternPropertiesAttribute,
32
- "additionalProperties" => JSON::Schema::AdditionalPropertiesAttribute,
33
- "items" => JSON::Schema::ItemsAttribute,
34
- "additionalItems" => JSON::Schema::AdditionalItemsAttribute,
35
- "dependencies" => JSON::Schema::DependenciesV4Attribute,
36
- "extends" => JSON::Schema::ExtendsAttribute,
37
- "$ref" => JSON::Schema::RefAttribute
9
+ 'type' => JSON::Schema::TypeV4Attribute,
10
+ 'allOf' => JSON::Schema::AllOfAttribute,
11
+ 'anyOf' => JSON::Schema::AnyOfAttribute,
12
+ 'oneOf' => JSON::Schema::OneOfAttribute,
13
+ 'not' => JSON::Schema::NotAttribute,
14
+ 'disallow' => JSON::Schema::DisallowAttribute,
15
+ 'format' => JSON::Schema::FormatAttribute,
16
+ 'maximum' => JSON::Schema::MaximumAttribute,
17
+ 'minimum' => JSON::Schema::MinimumAttribute,
18
+ 'minItems' => JSON::Schema::MinItemsAttribute,
19
+ 'maxItems' => JSON::Schema::MaxItemsAttribute,
20
+ 'minProperties' => JSON::Schema::MinPropertiesAttribute,
21
+ 'maxProperties' => JSON::Schema::MaxPropertiesAttribute,
22
+ 'uniqueItems' => JSON::Schema::UniqueItemsAttribute,
23
+ 'minLength' => JSON::Schema::MinLengthAttribute,
24
+ 'maxLength' => JSON::Schema::MaxLengthAttribute,
25
+ 'multipleOf' => JSON::Schema::MultipleOfAttribute,
26
+ 'enum' => JSON::Schema::EnumAttribute,
27
+ 'properties' => JSON::Schema::PropertiesV4Attribute,
28
+ 'required' => JSON::Schema::RequiredAttribute,
29
+ 'pattern' => JSON::Schema::PatternAttribute,
30
+ 'patternProperties' => JSON::Schema::PatternPropertiesAttribute,
31
+ 'additionalProperties' => JSON::Schema::AdditionalPropertiesAttribute,
32
+ 'items' => JSON::Schema::ItemsAttribute,
33
+ 'additionalItems' => JSON::Schema::AdditionalItemsAttribute,
34
+ 'dependencies' => JSON::Schema::DependenciesV4Attribute,
35
+ 'extends' => JSON::Schema::ExtendsAttribute,
36
+ '$ref' => JSON::Schema::RefAttribute,
38
37
  }
39
38
  @default_formats = {
40
39
  'date-time' => DateTimeV4Format,
41
40
  'ipv4' => IP4Format,
42
41
  'ipv6' => IP6Format,
43
- 'uri' => UriFormat
42
+ 'uri' => UriFormat,
44
43
  }
45
44
  @formats = @default_formats.clone
46
- @uri = JSON::Util::URI.parse("http://json-schema.org/draft-04/schema#")
47
- @names = ["draft4", "http://json-schema.org/draft-04/schema#"]
48
- @metaschema_name = "draft-04.json"
45
+ @uri = JSON::Util::URI.parse('http://json-schema.org/draft-04/schema#')
46
+ @names = ['draft4', 'http://json-schema.org/draft-04/schema#']
47
+ @metaschema_name = 'draft-04.json'
49
48
  end
50
49
 
51
- JSON::Validator.register_validator(self.new)
52
- JSON::Validator.register_default_validator(self.new)
50
+ JSON::Validator.register_validator(new)
51
+ JSON::Validator.register_default_validator(new)
53
52
  end
54
-
55
53
  end
56
54
  end
@@ -2,55 +2,55 @@ require 'json-schema/schema/validator'
2
2
 
3
3
  module JSON
4
4
  class Schema
5
-
6
5
  class Draft6 < Validator
7
6
  def initialize
8
7
  super
9
8
  @attributes = {
10
- "type" => JSON::Schema::TypeV4Attribute,
11
- "allOf" => JSON::Schema::AllOfAttribute,
12
- "anyOf" => JSON::Schema::AnyOfAttribute,
13
- "oneOf" => JSON::Schema::OneOfAttribute,
14
- "not" => JSON::Schema::NotAttribute,
15
- "disallow" => JSON::Schema::DisallowAttribute,
16
- "format" => JSON::Schema::FormatAttribute,
17
- "maximum" => JSON::Schema::MaximumAttribute,
18
- "minimum" => JSON::Schema::MinimumAttribute,
19
- "minItems" => JSON::Schema::MinItemsAttribute,
20
- "maxItems" => JSON::Schema::MaxItemsAttribute,
21
- "minProperties" => JSON::Schema::MinPropertiesAttribute,
22
- "maxProperties" => JSON::Schema::MaxPropertiesAttribute,
23
- "uniqueItems" => JSON::Schema::UniqueItemsAttribute,
24
- "minLength" => JSON::Schema::MinLengthAttribute,
25
- "maxLength" => JSON::Schema::MaxLengthAttribute,
26
- "multipleOf" => JSON::Schema::MultipleOfAttribute,
27
- "enum" => JSON::Schema::EnumAttribute,
28
- "properties" => JSON::Schema::PropertiesV4Attribute,
29
- "required" => JSON::Schema::RequiredAttribute,
30
- "pattern" => JSON::Schema::PatternAttribute,
31
- "patternProperties" => JSON::Schema::PatternPropertiesAttribute,
32
- "additionalProperties" => JSON::Schema::AdditionalPropertiesAttribute,
33
- "items" => JSON::Schema::ItemsAttribute,
34
- "additionalItems" => JSON::Schema::AdditionalItemsAttribute,
35
- "dependencies" => JSON::Schema::DependenciesV4Attribute,
36
- "extends" => JSON::Schema::ExtendsAttribute,
37
- "$ref" => JSON::Schema::RefAttribute
9
+ 'type' => JSON::Schema::TypeV4Attribute,
10
+ 'allOf' => JSON::Schema::AllOfAttribute,
11
+ 'anyOf' => JSON::Schema::AnyOfAttribute,
12
+ 'oneOf' => JSON::Schema::OneOfAttribute,
13
+ 'not' => JSON::Schema::NotAttribute,
14
+ 'disallow' => JSON::Schema::DisallowAttribute,
15
+ 'format' => JSON::Schema::FormatAttribute,
16
+ 'maximum' => JSON::Schema::MaximumAttribute,
17
+ 'minimum' => JSON::Schema::MinimumAttribute,
18
+ 'minItems' => JSON::Schema::MinItemsAttribute,
19
+ 'maxItems' => JSON::Schema::MaxItemsAttribute,
20
+ 'minProperties' => JSON::Schema::MinPropertiesAttribute,
21
+ 'maxProperties' => JSON::Schema::MaxPropertiesAttribute,
22
+ 'uniqueItems' => JSON::Schema::UniqueItemsAttribute,
23
+ 'minLength' => JSON::Schema::MinLengthAttribute,
24
+ 'maxLength' => JSON::Schema::MaxLengthAttribute,
25
+ 'multipleOf' => JSON::Schema::MultipleOfAttribute,
26
+ 'enum' => JSON::Schema::EnumAttribute,
27
+ 'properties' => JSON::Schema::PropertiesV4Attribute,
28
+ 'required' => JSON::Schema::RequiredAttribute,
29
+ 'pattern' => JSON::Schema::PatternAttribute,
30
+ 'patternProperties' => JSON::Schema::PatternPropertiesAttribute,
31
+ 'additionalProperties' => JSON::Schema::AdditionalPropertiesAttribute,
32
+ 'items' => JSON::Schema::ItemsAttribute,
33
+ 'additionalItems' => JSON::Schema::AdditionalItemsAttribute,
34
+ 'dependencies' => JSON::Schema::DependenciesV4Attribute,
35
+ 'extends' => JSON::Schema::ExtendsAttribute,
36
+ 'const' => JSON::Schema::ConstAttribute,
37
+ '$ref' => JSON::Schema::RefAttribute,
38
+ 'propertyNames' => JSON::Schema::PropertyNames,
38
39
  }
39
40
  @default_formats = {
40
41
  'date-time' => DateTimeV4Format,
41
42
  'ipv4' => IP4Format,
42
43
  'ipv6' => IP6Format,
43
- 'uri' => UriFormat
44
+ 'uri' => UriFormat,
44
45
  }
45
46
  @formats = @default_formats.clone
46
- @uri = JSON::Util::URI.parse("http://json-schema.org/draft-06/schema#")
47
- @names = ["draft6", "http://json-schema.org/draft-06/schema#"]
48
- @metaschema_name = "draft-06.json"
47
+ @uri = JSON::Util::URI.parse('http://json-schema.org/draft-06/schema#')
48
+ @names = ['draft6', 'http://json-schema.org/draft-06/schema#']
49
+ @metaschema_name = 'draft-06.json'
49
50
  end
50
51
 
51
- JSON::Validator.register_validator(self.new)
52
- JSON::Validator.register_default_validator(self.new)
52
+ JSON::Validator.register_validator(new)
53
+ JSON::Validator.register_default_validator(new)
53
54
  end
54
-
55
55
  end
56
56
  end
@@ -1,13 +1,12 @@
1
1
  module JSON
2
2
  class Schema
3
-
4
3
  class HyperDraft1 < Draft1
5
4
  def initialize
6
5
  super
7
- @uri = JSON::Util::URI.parse("http://json-schema.org/draft-01/hyper-schema#")
6
+ @uri = JSON::Util::URI.parse('http://json-schema.org/draft-01/hyper-schema#')
8
7
  end
9
8
 
10
- JSON::Validator.register_validator(self.new)
9
+ JSON::Validator.register_validator(new)
11
10
  end
12
11
  end
13
12
  end
@@ -1,13 +1,12 @@
1
1
  module JSON
2
2
  class Schema
3
-
4
3
  class HyperDraft2 < Draft2
5
4
  def initialize
6
5
  super
7
- @uri = JSON::Util::URI.parse("http://json-schema.org/draft-02/hyper-schema#")
6
+ @uri = JSON::Util::URI.parse('http://json-schema.org/draft-02/hyper-schema#')
8
7
  end
9
8
 
10
- JSON::Validator.register_validator(self.new)
9
+ JSON::Validator.register_validator(new)
11
10
  end
12
11
  end
13
12
  end
@@ -1,13 +1,12 @@
1
1
  module JSON
2
2
  class Schema
3
-
4
3
  class HyperDraft3 < Draft3
5
4
  def initialize
6
5
  super
7
- @uri = JSON::Util::URI.parse("http://json-schema.org/draft-03/hyper-schema#")
6
+ @uri = JSON::Util::URI.parse('http://json-schema.org/draft-03/hyper-schema#')
8
7
  end
9
8
 
10
- JSON::Validator.register_validator(self.new)
9
+ JSON::Validator.register_validator(new)
11
10
  end
12
11
  end
13
12
  end
@@ -1,13 +1,12 @@
1
1
  module JSON
2
2
  class Schema
3
-
4
3
  class HyperDraft4 < Draft4
5
4
  def initialize
6
5
  super
7
- @uri = JSON::Util::URI.parse("http://json-schema.org/draft-04/hyper-schema#")
6
+ @uri = JSON::Util::URI.parse('http://json-schema.org/draft-04/hyper-schema#')
8
7
  end
9
8
 
10
- JSON::Validator.register_validator(self.new)
9
+ JSON::Validator.register_validator(new)
11
10
  end
12
11
  end
13
12
  end
@@ -1,13 +1,12 @@
1
1
  module JSON
2
2
  class Schema
3
-
4
3
  class HyperDraft6 < Draft6
5
4
  def initialize
6
5
  super
7
- @uri = JSON::Util::URI.parse("http://json-schema.org/draft-06/hyper-schema#")
6
+ @uri = JSON::Util::URI.parse('http://json-schema.org/draft-06/hyper-schema#')
8
7
  end
9
8
 
10
- JSON::Validator.register_validator(self.new)
9
+ JSON::Validator.register_validator(new)
11
10
  end
12
11
  end
13
12
  end
data/lib/json-schema.rb CHANGED
@@ -14,6 +14,5 @@ require 'json-schema/schema'
14
14
  require 'json-schema/schema/reader'
15
15
  require 'json-schema/validator'
16
16
 
17
- Dir[File.join(File.dirname(__FILE__), "json-schema/attributes/*.rb")].each {|file| require file }
18
- Dir[File.join(File.dirname(__FILE__), "json-schema/attributes/formats/*.rb")].each {|file| require file }
19
- Dir[File.join(File.dirname(__FILE__), "json-schema/validators/*.rb")].sort!.each {|file| require file }
17
+ Dir[File.join(File.dirname(__FILE__), 'json-schema/attributes/**/*.rb')].each { |file| require file }
18
+ Dir[File.join(File.dirname(__FILE__), 'json-schema/validators/*.rb')].sort!.each { |file| require file }
@@ -1,40 +1,55 @@
1
1
  {
2
- "id": "http://json-schema.org/draft-06/schema#",
3
2
  "$schema": "http://json-schema.org/draft-06/schema#",
4
- "description": "Core schema meta-schema",
3
+ "$id": "http://json-schema.org/draft-06/schema#",
4
+ "title": "Core schema meta-schema",
5
5
  "definitions": {
6
6
  "schemaArray": {
7
7
  "type": "array",
8
8
  "minItems": 1,
9
9
  "items": { "$ref": "#" }
10
10
  },
11
- "positiveInteger": {
11
+ "nonNegativeInteger": {
12
12
  "type": "integer",
13
13
  "minimum": 0
14
14
  },
15
- "positiveIntegerDefault0": {
16
- "allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
15
+ "nonNegativeIntegerDefault0": {
16
+ "allOf": [
17
+ { "$ref": "#/definitions/nonNegativeInteger" },
18
+ { "default": 0 }
19
+ ]
17
20
  },
18
21
  "simpleTypes": {
19
- "enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
22
+ "enum": [
23
+ "array",
24
+ "boolean",
25
+ "integer",
26
+ "null",
27
+ "number",
28
+ "object",
29
+ "string"
30
+ ]
20
31
  },
21
32
  "stringArray": {
22
33
  "type": "array",
23
34
  "items": { "type": "string" },
24
- "minItems": 1,
25
- "uniqueItems": true
35
+ "uniqueItems": true,
36
+ "default": []
26
37
  }
27
38
  },
28
- "type": "object",
39
+ "type": ["object", "boolean"],
29
40
  "properties": {
30
- "id": {
41
+ "$id": {
31
42
  "type": "string",
32
- "format": "uri"
43
+ "format": "uri-reference"
33
44
  },
34
45
  "$schema": {
35
46
  "type": "string",
36
47
  "format": "uri"
37
48
  },
49
+ "$ref": {
50
+ "type": "string",
51
+ "format": "uri-reference"
52
+ },
38
53
  "title": {
39
54
  "type": "string"
40
55
  },
@@ -44,36 +59,27 @@
44
59
  "default": {},
45
60
  "multipleOf": {
46
61
  "type": "number",
47
- "minimum": 0,
48
- "exclusiveMinimum": true
62
+ "exclusiveMinimum": 0
49
63
  },
50
64
  "maximum": {
51
65
  "type": "number"
52
66
  },
53
67
  "exclusiveMaximum": {
54
- "type": "boolean",
55
- "default": false
68
+ "type": "number"
56
69
  },
57
70
  "minimum": {
58
71
  "type": "number"
59
72
  },
60
73
  "exclusiveMinimum": {
61
- "type": "boolean",
62
- "default": false
74
+ "type": "number"
63
75
  },
64
- "maxLength": { "$ref": "#/definitions/positiveInteger" },
65
- "minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
76
+ "maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
77
+ "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
66
78
  "pattern": {
67
79
  "type": "string",
68
80
  "format": "regex"
69
81
  },
70
- "additionalItems": {
71
- "anyOf": [
72
- { "type": "boolean" },
73
- { "$ref": "#" }
74
- ],
75
- "default": {}
76
- },
82
+ "additionalItems": { "$ref": "#" },
77
83
  "items": {
78
84
  "anyOf": [
79
85
  { "$ref": "#" },
@@ -81,22 +87,17 @@
81
87
  ],
82
88
  "default": {}
83
89
  },
84
- "maxItems": { "$ref": "#/definitions/positiveInteger" },
85
- "minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
90
+ "maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
91
+ "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
86
92
  "uniqueItems": {
87
93
  "type": "boolean",
88
94
  "default": false
89
95
  },
90
- "maxProperties": { "$ref": "#/definitions/positiveInteger" },
91
- "minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
96
+ "contains": { "$ref": "#" },
97
+ "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
98
+ "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
92
99
  "required": { "$ref": "#/definitions/stringArray" },
93
- "additionalProperties": {
94
- "anyOf": [
95
- { "type": "boolean" },
96
- { "$ref": "#" }
97
- ],
98
- "default": {}
99
- },
100
+ "additionalProperties": { "$ref": "#" },
100
101
  "definitions": {
101
102
  "type": "object",
102
103
  "additionalProperties": { "$ref": "#" },
@@ -121,6 +122,8 @@
121
122
  ]
122
123
  }
123
124
  },
125
+ "propertyNames": { "$ref": "#" },
126
+ "const": {},
124
127
  "enum": {
125
128
  "type": "array",
126
129
  "minItems": 1,
@@ -137,14 +140,11 @@
137
140
  }
138
141
  ]
139
142
  },
143
+ "format": { "type": "string" },
140
144
  "allOf": { "$ref": "#/definitions/schemaArray" },
141
145
  "anyOf": { "$ref": "#/definitions/schemaArray" },
142
146
  "oneOf": { "$ref": "#/definitions/schemaArray" },
143
147
  "not": { "$ref": "#" }
144
148
  },
145
- "dependencies": {
146
- "exclusiveMaximum": [ "maximum" ],
147
- "exclusiveMinimum": [ "minimum" ]
148
- },
149
149
  "default": {}
150
150
  }