json-schema 2.5.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4d20081a44ab34c2a1d12268a7e4160b4070221
4
- data.tar.gz: a9b98f1d541ad64563095ee77d03738e3d6fbfaa
3
+ metadata.gz: 001e9abbf83e74538a97e0cdb3088cf2b3d415c4
4
+ data.tar.gz: a7dbb4c977abd6b70c8b019cf85670d4113c3e29
5
5
  SHA512:
6
- metadata.gz: 433b1267a8f4902cf007e6407fbd9bc253cd5884ae9c1311825cdf1e019c784239c2e7189e11e8d752449c27a5f74f22c00dbb6205ae3ae3d5342874628584a4
7
- data.tar.gz: 57f5da1f4a399df4c9025d6955a6d554fc41c23ac009651501f7badb5c622db272a53bbd3d3a2cac849b34055cbbb89d5c99775968e1b69ff8ddc3933dfc8966
6
+ metadata.gz: 1414dd9bee261301c502b41b30f5ba4c3dd617676acc06e5ace1a35bec1a115aebe4e996a886f981f4ced69679ae0ffed6f1d1aad4f17c16548df61e094c9bfb
7
+ data.tar.gz: e661d1bbf6d34d40e963580fc950d7201a2e4670ba90749dee5f76bc33045f6b55a973d17897fdcb7c101fcaafabf2ec38116a93d9fa22d9dd10869e8eabd907
@@ -26,7 +26,7 @@ From the git repo:
26
26
 
27
27
  <pre>
28
28
  $ gem build json-schema.gemspec
29
- $ gem install json-schema-2.4.1.gem
29
+ $ gem install json-schema-2.5.0.gem
30
30
  </pre>
31
31
 
32
32
 
@@ -40,6 +40,8 @@ By default, the validator uses the "JSON Schema Draft 4":http://tools.ietf.org/h
40
40
 
41
41
  h3. Validate Ruby objects against a Ruby schema
42
42
 
43
+ For further information on json schema itself refer to <a href="http://spacetelescope.github.io/understanding-json-schema/">Understanding JSON Schema</a>.
44
+
43
45
  <pre>
44
46
  require 'rubygems'
45
47
  require 'json-schema'
@@ -7,10 +7,7 @@ module JSON
7
7
  return unless data.is_a?(String)
8
8
  error_message = "The property '#{build_fragment(fragments)}' must be a valid URI"
9
9
  begin
10
- # TODO
11
- # Addressable only throws an exception on to_s for invalid URI strings, although it
12
- # probably should throughout parse already - https://github.com/sporkmonger/addressable/issues/177
13
- Addressable::URI.parse(data).to_s
10
+ Addressable::URI.parse(data)
14
11
  rescue Addressable::URI::InvalidURIError
15
12
  validation_error(processor, error_message, fragments, current_schema, self, options[:record_errors])
16
13
  end
@@ -4,39 +4,52 @@ module JSON
4
4
  class Schema
5
5
  class OneOfAttribute < Attribute
6
6
  def self.validate(current_schema, data, fragments, processor, validator, options = {})
7
- validation_errors = 0
7
+ errors = Hash.new { |hsh, k| hsh[k] = [] }
8
+
9
+ validation_error_count = 0
8
10
  one_of = current_schema.schema['oneOf']
9
11
 
10
12
  original_data = data.is_a?(Hash) ? data.clone : data
11
13
  success_data = nil
12
14
 
13
- one_of.each do |element|
14
- schema = JSON::Schema.new(element,current_schema.uri,validator)
15
+ valid = false
15
16
 
17
+ one_of.each_with_index do |element, schema_index|
18
+ schema = JSON::Schema.new(element,current_schema.uri,validator)
19
+ pre_validation_error_count = validation_errors(processor).count
16
20
  begin
17
- # need to raise exceptions on error because
18
- # schema.validate doesn't reliably return true/false
19
- schema.validate(data,fragments,processor,options.merge(:record_errors => false))
21
+ schema.validate(data,fragments,processor,options)
20
22
  success_data = data.is_a?(Hash) ? data.clone : data
23
+ valid = true
21
24
  rescue ValidationError
22
- validation_errors += 1
25
+ valid = false
23
26
  end
24
27
 
28
+ diff = validation_errors(processor).count - pre_validation_error_count
29
+ valid = false if diff > 0
30
+ validation_error_count += 1 if !valid
31
+ while diff > 0
32
+ diff = diff - 1
33
+ errors["oneOf ##{schema_index}"].push(validation_errors(processor).pop)
34
+ end
25
35
  data = original_data
26
36
  end
27
37
 
28
- if validation_errors == one_of.length - 1
38
+
39
+
40
+ if validation_error_count == one_of.length - 1
29
41
  data = success_data
30
42
  return
31
43
  end
32
44
 
33
- if validation_errors == one_of.length
45
+ if validation_error_count == one_of.length
34
46
  message = "The property '#{build_fragment(fragments)}' of type #{data.class} did not match any of the required schemas"
35
47
  else
36
48
  message = "The property '#{build_fragment(fragments)}' of type #{data.class} matched more than one of the required schemas"
37
49
  end
38
50
 
39
51
  validation_error(processor, message, fragments, current_schema, self, options[:record_errors]) if message
52
+ validation_errors(processor).last.sub_errors = errors if message
40
53
  end
41
54
  end
42
55
  end
@@ -56,8 +56,8 @@ module JSON
56
56
  end
57
57
 
58
58
  if diff.size > 0
59
- properties = data.to_a.map { |(key, _)| key }.join(', ')
60
- message = "The property '#{build_fragment(fragments)}' contained undefined properties: '#{properties}"
59
+ properties = diff.keys.join(', ')
60
+ message = "The property '#{build_fragment(fragments)}' contained undefined properties: '#{properties}'"
61
61
  validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
62
62
  end
63
63
  end
@@ -1,14 +1,20 @@
1
+ require 'set'
2
+
1
3
  # This is a hack that I don't want to ever use anywhere else or repeat EVER, but we need enums to be
2
- # an Array to pass schema validation. But we also want fast lookup! And we can't use sets because of
3
- # backport support... so...
4
+ # an Array to pass schema validation. But we also want fast lookup!
4
5
 
5
6
  class ArraySet < Array
6
- def include?(obj)
7
- # On first invocation create a HASH (yeah, yeah) to act as our set given the array values
8
- if !defined? @array_values
9
- @array_values = {}
10
- self.each {|x| @array_values[x] = 1}
11
- end
12
- @array_values.has_key? obj
13
- end
14
- end
7
+ def include?(obj)
8
+ if !defined? @values
9
+ @values = Set.new
10
+ self.each { |x| @values << convert_to_float_if_fixnum(x) }
11
+ end
12
+ @values.include?(convert_to_float_if_fixnum(obj))
13
+ end
14
+
15
+ private
16
+
17
+ def convert_to_float_if_fixnum(value)
18
+ value.is_a?(Fixnum) ? value.to_f : value
19
+ end
20
+ end
@@ -129,7 +129,6 @@ module JSON
129
129
 
130
130
  def load_ref_schema(parent_schema, ref)
131
131
  schema_uri = absolutize_ref_uri(ref, parent_schema.uri)
132
-
133
132
  return true if self.class.schema_loaded?(schema_uri)
134
133
 
135
134
  schema = @options[:schema_reader].read(schema_uri)
@@ -139,6 +138,7 @@ module JSON
139
138
 
140
139
  def absolutize_ref_uri(ref, parent_schema_uri)
141
140
  ref_uri = Addressable::URI.parse(ref)
141
+ ref_uri.fragment = ''
142
142
 
143
143
  return ref_uri if ref_uri.absolute?
144
144
  # This is a self reference and thus the schema does not need to be re-loaded
@@ -0,0 +1,13 @@
1
+ module JSON
2
+ class Schema
3
+
4
+ class HyperDraft1 < Draft1
5
+ def initialize
6
+ super
7
+ @uri = Addressable::URI.parse("http://json-schema.org/draft-01/hyper-schema#")
8
+ end
9
+
10
+ JSON::Validator.register_validator(self.new)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module JSON
2
+ class Schema
3
+
4
+ class HyperDraft2 < Draft2
5
+ def initialize
6
+ super
7
+ @uri = Addressable::URI.parse("http://json-schema.org/draft-02/hyper-schema#")
8
+ end
9
+
10
+ JSON::Validator.register_validator(self.new)
11
+ end
12
+ end
13
+ end
@@ -8,7 +8,6 @@ module JSON
8
8
  end
9
9
 
10
10
  JSON::Validator.register_validator(self.new)
11
- JSON::Validator.register_default_validator(self.new)
12
11
  end
13
12
  end
14
13
  end
@@ -15,10 +15,15 @@ class JSONSchemaDraft1Test < Minitest::Test
15
15
 
16
16
  include ArrayValidation::ItemsTests
17
17
 
18
+ include EnumValidation::General
19
+ include EnumValidation::V1_V2
20
+
18
21
  include NumberValidation::MinMaxTests
19
22
 
20
23
  include ObjectValidation::AdditionalPropertiesTests
21
24
 
25
+ include StrictValidation
26
+
22
27
  include StringValidation::ValueTests
23
28
  include StringValidation::FormatTests
24
29
  include StringValidation::DateAndTimeFormatTests
@@ -50,41 +55,6 @@ class JSONSchemaDraft1Test < Minitest::Test
50
55
  assert_valid schema, data
51
56
  end
52
57
 
53
- def test_enum
54
- # Set up the default datatype
55
- schema = {
56
- "properties" => {
57
- "a" => {"enum" => [1,'boo',[1,2,3],{"a" => "b"}], "optional" => true}
58
- }
59
- }
60
-
61
- data = {
62
- "a" => nil
63
- }
64
-
65
- # Make sure all of the above are valid...
66
- data["a"] = 1
67
- assert_valid schema, data
68
-
69
- data["a"] = 'boo'
70
- assert_valid schema, data
71
-
72
- data["a"] = [1,2,3]
73
- assert_valid schema, data
74
-
75
- data["a"] = {"a" => "b"}
76
- assert_valid schema, data
77
-
78
- # Test something that doesn't exist
79
- data["a"] = 'taco'
80
- refute_valid schema, data
81
-
82
- # Try it without the key
83
- data = {}
84
- assert_valid schema, data
85
- end
86
-
87
-
88
58
  def test_max_decimal
89
59
  # Set up the default datatype
90
60
  schema = {
@@ -20,11 +20,16 @@ class JSONSchemaDraft2Test < Minitest::Test
20
20
  include ArrayValidation::ItemsTests
21
21
  include ArrayValidation::UniqueItemsTests
22
22
 
23
+ include EnumValidation::General
24
+ include EnumValidation::V1_V2
25
+
23
26
  include NumberValidation::MinMaxTests
24
27
  include NumberValidation::MultipleOfTests
25
28
 
26
29
  include ObjectValidation::AdditionalPropertiesTests
27
30
 
31
+ include StrictValidation
32
+
28
33
  include StringValidation::ValueTests
29
34
  include StringValidation::FormatTests
30
35
  include StringValidation::DateAndTimeFormatTests
@@ -56,40 +61,6 @@ class JSONSchemaDraft2Test < Minitest::Test
56
61
  assert_valid schema, data
57
62
  end
58
63
 
59
- def test_enum
60
- # Set up the default datatype
61
- schema = {
62
- "properties" => {
63
- "a" => {"enum" => [1,'boo',[1,2,3],{"a" => "b"}], "optional" => true}
64
- }
65
- }
66
-
67
- data = {
68
- "a" => nil
69
- }
70
-
71
- # Make sure all of the above are valid...
72
- data["a"] = 1
73
- assert_valid schema, data
74
-
75
- data["a"] = 'boo'
76
- assert_valid schema, data
77
-
78
- data["a"] = [1,2,3]
79
- assert_valid schema, data
80
-
81
- data["a"] = {"a" => "b"}
82
- assert_valid schema, data
83
-
84
- # Test something that doesn't exist
85
- data["a"] = 'taco'
86
- refute_valid schema, data
87
-
88
- # Try it without the key
89
- data = {}
90
- assert_valid schema, data
91
- end
92
-
93
64
  def test_disallow
94
65
  # Set up the default datatype
95
66
  schema = {
@@ -22,12 +22,17 @@ class JSONSchemaDraft3Test < Minitest::Test
22
22
  include ArrayValidation::AdditionalItemsTests
23
23
  include ArrayValidation::UniqueItemsTests
24
24
 
25
+ include EnumValidation::General
26
+ include EnumValidation::V3_V4
27
+
25
28
  include NumberValidation::MinMaxTests
26
29
  include NumberValidation::MultipleOfTests
27
30
 
28
31
  include ObjectValidation::AdditionalPropertiesTests
29
32
  include ObjectValidation::PatternPropertiesTests
30
33
 
34
+ include StrictValidation
35
+
31
36
  include StringValidation::ValueTests
32
37
  include StringValidation::FormatTests
33
38
  include StringValidation::DateAndTimeFormatTests
@@ -94,28 +99,6 @@ class JSONSchemaDraft3Test < Minitest::Test
94
99
  assert_valid schema, data
95
100
  end
96
101
 
97
- def test_strict_properties
98
- schema = {
99
- "$schema" => "http://json-schema.org/draft-03/schema#",
100
- "properties" => {
101
- "a" => {"type" => "string"},
102
- "b" => {"type" => "string"}
103
- }
104
- }
105
-
106
- data = {"a" => "a"}
107
- assert(!JSON::Validator.validate(schema,data,:strict => true))
108
-
109
- data = {"b" => "b"}
110
- assert(!JSON::Validator.validate(schema,data,:strict => true))
111
-
112
- data = {"a" => "a", "b" => "b"}
113
- assert(JSON::Validator.validate(schema,data,:strict => true))
114
-
115
- data = {"a" => "a", "b" => "b", "c" => "c"}
116
- assert(!JSON::Validator.validate(schema,data,:strict => true))
117
- end
118
-
119
102
  def test_strict_properties_required_props
120
103
  schema = {
121
104
  "$schema" => "http://json-schema.org/draft-03/schema#",
@@ -193,41 +176,6 @@ class JSONSchemaDraft3Test < Minitest::Test
193
176
  assert(!JSON::Validator.validate(schema,data,:strict => true))
194
177
  end
195
178
 
196
- def test_enum
197
- # Set up the default datatype
198
- schema = {
199
- "$schema" => "http://json-schema.org/draft-03/schema#",
200
- "properties" => {
201
- "a" => {"enum" => [1,'boo',[1,2,3],{"a" => "b"}]}
202
- }
203
- }
204
-
205
- data = {
206
- "a" => nil
207
- }
208
-
209
- # Make sure all of the above are valid...
210
- data["a"] = 1
211
- assert_valid schema, data
212
-
213
- data["a"] = 'boo'
214
- assert_valid schema, data
215
-
216
- data["a"] = [1,2,3]
217
- assert_valid schema, data
218
-
219
- data["a"] = {"a" => "b"}
220
- assert_valid schema, data
221
-
222
- # Test something that doesn't exist
223
- data["a"] = 'taco'
224
- refute_valid schema, data
225
-
226
- # Try it without the key
227
- data = {}
228
- assert_valid schema, data
229
- end
230
-
231
179
  def test_disallow
232
180
  # Set up the default datatype
233
181
  schema = {
@@ -22,12 +22,17 @@ class JSONSchemaDraft4Test < Minitest::Test
22
22
  include ArrayValidation::AdditionalItemsTests
23
23
  include ArrayValidation::UniqueItemsTests
24
24
 
25
+ include EnumValidation::General
26
+ include EnumValidation::V3_V4
27
+
25
28
  include NumberValidation::MinMaxTests
26
29
  include NumberValidation::MultipleOfTests
27
30
 
28
31
  include ObjectValidation::AdditionalPropertiesTests
29
32
  include ObjectValidation::PatternPropertiesTests
30
33
 
34
+ include StrictValidation
35
+
31
36
  include StringValidation::ValueTests
32
37
  include StringValidation::FormatTests
33
38
 
@@ -159,58 +164,6 @@ class JSONSchemaDraft4Test < Minitest::Test
159
164
  assert(!JSON::Validator.validate(schema,data,:strict => true))
160
165
  end
161
166
 
162
- def test_enum
163
- # Set up the default datatype
164
- schema = {
165
- "$schema" => "http://json-schema.org/draft-04/schema#",
166
- "properties" => {
167
- "a" => {"enum" => [1,'boo',[1,2,3],{"a" => "b"}]}
168
- }
169
- }
170
-
171
- data = {
172
- "a" => nil
173
- }
174
-
175
- # Make sure all of the above are valid...
176
- data["a"] = 1
177
- assert_valid schema, data
178
-
179
- data["a"] = 'boo'
180
- assert_valid schema, data
181
-
182
- data["a"] = [1,2,3]
183
- assert_valid schema, data
184
-
185
- data["a"] = {"a" => "b"}
186
- assert_valid schema, data
187
-
188
- # Test something that doesn't exist
189
- data["a"] = 'taco'
190
- refute_valid schema, data
191
-
192
- # Try it without the key
193
- data = {}
194
- assert_valid schema, data
195
- end
196
-
197
- def test_enum_with_schema_validation
198
- schema = {
199
- "$schema" => "http://json-schema.org/draft-04/schema#",
200
- "properties" => {
201
- "a" => {"enum" => [1,'boo',[1,2,3],{"a" => "b"}]}
202
- }
203
- }
204
-
205
- data = {
206
- "a" => nil
207
- }
208
-
209
- # Make sure all of the above are valid...
210
- data["a"] = 1
211
- assert(JSON::Validator.validate(schema,data,:validate_schema => true))
212
- end
213
-
214
167
  def test_list_option
215
168
  schema = {
216
169
  "$schema" => "http://json-schema.org/draft-04/schema#",
@@ -0,0 +1,40 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+
3
+ class LoadRefSchemaTests < Minitest::Test
4
+ def load_other_schema
5
+ JSON::Validator.add_schema(JSON::Schema.new(
6
+ {
7
+ '$schema' => 'http://json-schema.org/draft-04/schema#',
8
+ 'type' => 'object',
9
+ 'properties' => {
10
+ "title" => {
11
+ "type" => "string"
12
+ }
13
+ }
14
+ },
15
+ Addressable::URI.parse("http://example.com/schema#")
16
+ ))
17
+ end
18
+
19
+ def test_cached_schema
20
+ schema_url = "http://example.com/schema#"
21
+ schema = {
22
+ "$ref" => schema_url
23
+ }
24
+ data = {}
25
+ load_other_schema
26
+ validator = JSON::Validator.new(schema, data)
27
+ assert JSON::Validator.schema_loaded?(schema_url)
28
+ end
29
+
30
+ def test_cached_schema_with_fragment
31
+ schema_url = "http://example.com/schema#"
32
+ schema = {
33
+ "$ref" => "#{schema_url}/properties/title"
34
+ }
35
+ data = {}
36
+ load_other_schema
37
+ validator = JSON::Validator.new(schema, data)
38
+ assert JSON::Validator.schema_loaded?(schema_url)
39
+ end
40
+ end
@@ -29,4 +29,57 @@ class OneOfTest < Minitest::Test
29
29
  refute_valid schema, { "a" => 5 }
30
30
  end
31
31
 
32
+ def test_one_of_sub_errors
33
+ schema = {
34
+ "$schema" => "http://json-schema.org/draft-04/schema#",
35
+ "oneOf" => [
36
+ {
37
+ "properties" => {"a" => {"type" => "string", "pattern" => "foo"}},
38
+ },
39
+ {
40
+ "properties" => {"a" => {"type" => "string", "pattern" => "bar"}},
41
+ },
42
+ {
43
+ "properties" => {"a" => {"type" => "number", "minimum" => 10}},
44
+ }
45
+ ]
46
+ }
47
+
48
+ errors = JSON::Validator.fully_validate(schema, { "a" => 5 }, :errors_as_objects => true)
49
+ nested_errors = errors[0][:errors]
50
+ assert_equal([:oneof_0,:oneof_1,:oneof_2], nested_errors.keys, 'should have nested errors for each allOf subschema')
51
+ assert_match(/the property '#\/a' of type Fixnum did not match the following type: string/i, nested_errors[:oneof_0][0][:message])
52
+ assert_match(/the property '#\/a' did not have a minimum value of 10, inclusively/i, nested_errors[:oneof_2][0][:message])
53
+ end
54
+
55
+ def test_one_of_sub_errors_message
56
+ schema = {
57
+ "$schema" => "http://json-schema.org/draft-04/schema#",
58
+ "oneOf" => [
59
+ {
60
+ "properties" => {"a" => {"type" => "string", "pattern" => "foo"}},
61
+ },
62
+ {
63
+ "properties" => {"a" => {"type" => "string", "pattern" => "bar"}},
64
+ },
65
+ {
66
+ "properties" => {"a" => {"type" => "number", "minimum" => 10}},
67
+ }
68
+ ]
69
+ }
70
+
71
+ errors = JSON::Validator.fully_validate(schema, { "a" => 5 })
72
+ expected_message = """The property '#/' of type Hash did not match any of the required schemas. The schema specific errors were:
73
+
74
+ - oneOf #0:
75
+ - The property '#/a' of type Fixnum did not match the following type: string
76
+ - oneOf #1:
77
+ - The property '#/a' of type Fixnum did not match the following type: string
78
+ - oneOf #2:
79
+ - The property '#/a' did not have a minimum value of 10, inclusively"""
80
+
81
+ assert_equal(expected_message, errors[0])
82
+
83
+ end
84
+
32
85
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json-schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenny Hoxworth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-03 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.3'
75
+ version: 2.3.7
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.3'
82
+ version: 2.3.7
83
83
  description:
84
84
  email: hoxworth@gmail.com
85
85
  executables: []
@@ -129,7 +129,6 @@ files:
129
129
  - lib/json-schema/errors/schema_error.rb
130
130
  - lib/json-schema/errors/validation_error.rb
131
131
  - lib/json-schema/schema.rb
132
- - lib/json-schema/schema/#validator.rb#
133
132
  - lib/json-schema/schema/reader.rb
134
133
  - lib/json-schema/schema/validator.rb
135
134
  - lib/json-schema/util/array_set.rb
@@ -140,6 +139,8 @@ files:
140
139
  - lib/json-schema/validators/draft2.rb
141
140
  - lib/json-schema/validators/draft3.rb
142
141
  - lib/json-schema/validators/draft4.rb
142
+ - lib/json-schema/validators/hyper-draft1.rb
143
+ - lib/json-schema/validators/hyper-draft2.rb
143
144
  - lib/json-schema/validators/hyper-draft4.rb
144
145
  - resources/draft-01.json
145
146
  - resources/draft-02.json
@@ -191,6 +192,7 @@ files:
191
192
  - test/test_jsonschema_draft3.rb
192
193
  - test/test_jsonschema_draft4.rb
193
194
  - test/test_list_option.rb
195
+ - test/test_load_ref_schema.rb
194
196
  - test/test_merge_missing_values.rb
195
197
  - test/test_minitems.rb
196
198
  - test/test_one_of.rb
@@ -221,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
223
  version: '1.8'
222
224
  requirements: []
223
225
  rubyforge_project:
224
- rubygems_version: 2.2.2
226
+ rubygems_version: 2.4.5
225
227
  signing_key:
226
228
  specification_version: 4
227
229
  summary: Ruby JSON Schema Validator
@@ -245,6 +247,7 @@ test_files:
245
247
  - test/test_jsonschema_draft3.rb
246
248
  - test/test_jsonschema_draft4.rb
247
249
  - test/test_list_option.rb
250
+ - test/test_load_ref_schema.rb
248
251
  - test/test_merge_missing_values.rb
249
252
  - test/test_minitems.rb
250
253
  - test/test_one_of.rb
@@ -282,3 +285,4 @@ test_files:
282
285
  - test/schemas/relative_definition_schema.json
283
286
  - test/schemas/self_link_schema.json
284
287
  - test/schemas/up_link_schema.json
288
+ has_rdoc:
@@ -1,37 +0,0 @@
1
-
2
- module JSON
3
- class Schema
4
- class Validator
5
- attr_accessor :attributes, :formats, :uri, :names
6
- attr_reader :default_formats
7
-
8
- def initialize()
9
- @attributes = {}
10
- @formats = {}
11
- @default_formats = {}
12
- @uri = nil
13
- @names = []
14
- @metaschema_name = ''
15
- end
16
-
17
- def extend_schema_definition(schema_uri)
18
- validator = JSON::Validator.validator_for(schema_uri)
19
- @attributes.merge!(validator.attributes)
20
- end
21
-
22
- def validate(current_schema, data, fragments, processor, options = {})
23
- current_schema.schema.each do |attr_name,attribute|
24
- if @attributes.has_key?(attr_name.to_s)
25
- @attributes[attr_name.to_s].validate(current_schema, data, fragments, processor, self, options)
26
- end
27
- end
28
- data
29
- end
30
-
31
- def metaschema
32
- resources = File.expand_path('../../../../resources', __FILE__)
33
- File.join(resources, @metaschema_name)
34
- end
35
- end
36
- end
37
- end