json-schema 2.5.1 → 2.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.textile +2 -2
  3. data/lib/json-schema/attributes/properties.rb +1 -1
  4. data/lib/json-schema/validator.rb +14 -6
  5. metadata +6 -121
  6. data/test/data/all_of_ref_data.json +0 -3
  7. data/test/data/any_of_ref_data.json +0 -7
  8. data/test/data/bad_data_1.json +0 -3
  9. data/test/data/good_data_1.json +0 -3
  10. data/test/data/one_of_ref_links_data.json +0 -5
  11. data/test/schemas/address_microformat.json +0 -18
  12. data/test/schemas/all_of_ref_base_schema.json +0 -6
  13. data/test/schemas/all_of_ref_schema.json +0 -7
  14. data/test/schemas/any_of_ref_jane_schema.json +0 -4
  15. data/test/schemas/any_of_ref_jimmy_schema.json +0 -4
  16. data/test/schemas/any_of_ref_john_schema.json +0 -4
  17. data/test/schemas/any_of_ref_schema.json +0 -15
  18. data/test/schemas/definition_schema.json +0 -15
  19. data/test/schemas/extends_and_additionalProperties-1-filename.schema.json +0 -34
  20. data/test/schemas/extends_and_additionalProperties-1-ref.schema.json +0 -34
  21. data/test/schemas/extends_and_additionalProperties-2-filename.schema.json +0 -33
  22. data/test/schemas/extends_and_additionalProperties-2-ref.schema.json +0 -33
  23. data/test/schemas/good_schema_1.json +0 -10
  24. data/test/schemas/good_schema_2.json +0 -10
  25. data/test/schemas/good_schema_extends1.json +0 -10
  26. data/test/schemas/good_schema_extends2.json +0 -13
  27. data/test/schemas/inner.schema.json +0 -21
  28. data/test/schemas/one_of_ref_links_schema.json +0 -16
  29. data/test/schemas/ref john with spaces schema.json +0 -11
  30. data/test/schemas/relative_definition_schema.json +0 -8
  31. data/test/schemas/self_link_schema.json +0 -17
  32. data/test/schemas/up_link_schema.json +0 -17
  33. data/test/test_all_of_ref_schema.rb +0 -35
  34. data/test/test_any_of_ref_schema.rb +0 -35
  35. data/test/test_bad_schema_ref.rb +0 -39
  36. data/test/test_common_test_suite.rb +0 -66
  37. data/test/test_custom_format.rb +0 -116
  38. data/test/test_definition.rb +0 -15
  39. data/test/test_extended_schema.rb +0 -62
  40. data/test/test_extends_and_additionalProperties.rb +0 -52
  41. data/test/test_files_v3.rb +0 -43
  42. data/test/test_fragment_resolution.rb +0 -30
  43. data/test/test_fragment_validation_with_ref.rb +0 -34
  44. data/test/test_full_validation.rb +0 -208
  45. data/test/test_helper.rb +0 -47
  46. data/test/test_initialize_data.rb +0 -118
  47. data/test/test_jsonschema_draft1.rb +0 -141
  48. data/test/test_jsonschema_draft2.rb +0 -113
  49. data/test/test_jsonschema_draft3.rb +0 -450
  50. data/test/test_jsonschema_draft4.rb +0 -657
  51. data/test/test_list_option.rb +0 -21
  52. data/test/test_load_ref_schema.rb +0 -40
  53. data/test/test_merge_missing_values.rb +0 -45
  54. data/test/test_minitems.rb +0 -16
  55. data/test/test_one_of.rb +0 -85
  56. data/test/test_ruby_schema.rb +0 -59
  57. data/test/test_schema_loader.rb +0 -74
  58. data/test/test_schema_type_attribute.rb +0 -20
  59. data/test/test_schema_validation.rb +0 -185
  60. data/test/test_stringify.rb +0 -48
  61. data/test/test_uri_related.rb +0 -67
  62. data/test/test_validator.rb +0 -53
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 001e9abbf83e74538a97e0cdb3088cf2b3d415c4
4
- data.tar.gz: a7dbb4c977abd6b70c8b019cf85670d4113c3e29
3
+ metadata.gz: 0448122a379f2472a1f14ca8cc02dfe622f64c4d
4
+ data.tar.gz: b9ef1a82305726ab44107d6fd078aad9517d33de
5
5
  SHA512:
6
- metadata.gz: 1414dd9bee261301c502b41b30f5ba4c3dd617676acc06e5ace1a35bec1a115aebe4e996a886f981f4ced69679ae0ffed6f1d1aad4f17c16548df61e094c9bfb
7
- data.tar.gz: e661d1bbf6d34d40e963580fc950d7201a2e4670ba90749dee5f76bc33045f6b55a973d17897fdcb7c101fcaafabf2ec38116a93d9fa22d9dd10869e8eabd907
6
+ metadata.gz: 86eeeb455c88470dd99dfe377e30f12f750dc55b62085131995b5079fbd2cd91515b9eb27a06fe15ffb6084f39cba5c6026cef8c78491a8d344279c621cf3886
7
+ data.tar.gz: 8d3cce427d1c3d1526bfa8b46ccb62a54683ac7cc19e0eb64a7b5a2bc3da8130343db1807fd227c814a64e7141f6fb983cb705fa4660faf46c5201250d662303
data/README.textile CHANGED
@@ -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.5.0.gem
29
+ $ gem install json-schema-2.5.2.gem
30
30
  </pre>
31
31
 
32
32
 
@@ -82,7 +82,7 @@ JSON::Validator.validate('user.json', data, :list => true)
82
82
 
83
83
  h3. Strictly validate an object's properties
84
84
 
85
- With the <code>:strict</code> option, validation fails when an object contains properties that are not defined in the schema's property list or doesn't match the <code>additionalProperties</code> property. Furthermore, all properties are treated as <code>required</code> by default.
85
+ With the <code>:strict</code> option, validation fails when an object contains properties that are not defined in the schema's property list or doesn't match the <code>additionalProperties</code> property. Furthermore, all properties are treated as <code>required</code> regardless of <code>required</code> properties set in the schema.
86
86
 
87
87
  <pre>
88
88
  require 'rubygems'
@@ -16,7 +16,7 @@ module JSON
16
16
 
17
17
  if !data.key?(property) &&
18
18
  options[:insert_defaults] &&
19
- property_schema['default'] &&
19
+ property_schema.has_key?('default') &&
20
20
  !property_schema['readonly']
21
21
  default = property_schema['default']
22
22
  data[property] = default.is_a?(Hash) ? default.clone : default
@@ -46,6 +46,7 @@ module JSON
46
46
  @validation_options = @options[:record_errors] ? {:record_errors => true} : {}
47
47
  @validation_options[:insert_defaults] = true if @options[:insert_defaults]
48
48
  @validation_options[:strict] = true if @options[:strict] == true
49
+ @validation_options[:clear_cache] = false if @options[:clear_cache] == false
49
50
 
50
51
  @@mutex.synchronize { @base_schema = initialize_schema(schema_data) }
51
52
  @original_data = data
@@ -372,20 +373,20 @@ module JSON
372
373
  @@default_validator = v
373
374
  end
374
375
 
375
- def register_format_validator(format, validation_proc, versions = ["draft1", "draft2", "draft3", "draft4"])
376
+ def register_format_validator(format, validation_proc, versions = ["draft1", "draft2", "draft3", "draft4", nil])
376
377
  custom_format_validator = JSON::Schema::CustomFormat.new(validation_proc)
377
378
  validators_for_names(versions).each do |validator|
378
379
  validator.formats[format.to_s] = custom_format_validator
379
380
  end
380
381
  end
381
382
 
382
- def deregister_format_validator(format, versions = ["draft1", "draft2", "draft3", "draft4"])
383
+ def deregister_format_validator(format, versions = ["draft1", "draft2", "draft3", "draft4", nil])
383
384
  validators_for_names(versions).each do |validator|
384
385
  validator.formats[format.to_s] = validator.default_formats[format.to_s]
385
386
  end
386
387
  end
387
388
 
388
- def restore_default_formats(versions = ["draft1", "draft2", "draft3", "draft4"])
389
+ def restore_default_formats(versions = ["draft1", "draft2", "draft3", "draft4", nil])
389
390
  validators_for_names(versions).each do |validator|
390
391
  validator.formats = validator.default_formats.clone
391
392
  end
@@ -481,9 +482,16 @@ module JSON
481
482
  private
482
483
 
483
484
  def validators_for_names(names)
484
- names.map! { |name| name.to_s }
485
- validators.reduce([]) do |memo, (_, validator)|
486
- memo.tap { |m| m << validator if (validator.names & names).any? }
485
+ names = names.map { |name| name.to_s }
486
+ [].tap do |memo|
487
+ validators.each do |_, validator|
488
+ if (validator.names & names).any?
489
+ memo << validator
490
+ end
491
+ end
492
+ if names.include?('')
493
+ memo << default_validator
494
+ end
487
495
  end
488
496
  end
489
497
  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.1
4
+ version: 2.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenny Hoxworth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-23 00:00:00.000000000 Z
11
+ date: 2015-11-24 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.7
75
+ version: 2.3.8
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.7
82
+ version: 2.3.8
83
83
  description:
84
84
  email: hoxworth@gmail.com
85
85
  executables: []
@@ -146,63 +146,6 @@ files:
146
146
  - resources/draft-02.json
147
147
  - resources/draft-03.json
148
148
  - resources/draft-04.json
149
- - test/data/all_of_ref_data.json
150
- - test/data/any_of_ref_data.json
151
- - test/data/bad_data_1.json
152
- - test/data/good_data_1.json
153
- - test/data/one_of_ref_links_data.json
154
- - test/schemas/address_microformat.json
155
- - test/schemas/all_of_ref_base_schema.json
156
- - test/schemas/all_of_ref_schema.json
157
- - test/schemas/any_of_ref_jane_schema.json
158
- - test/schemas/any_of_ref_jimmy_schema.json
159
- - test/schemas/any_of_ref_john_schema.json
160
- - test/schemas/any_of_ref_schema.json
161
- - test/schemas/definition_schema.json
162
- - test/schemas/extends_and_additionalProperties-1-filename.schema.json
163
- - test/schemas/extends_and_additionalProperties-1-ref.schema.json
164
- - test/schemas/extends_and_additionalProperties-2-filename.schema.json
165
- - test/schemas/extends_and_additionalProperties-2-ref.schema.json
166
- - test/schemas/good_schema_1.json
167
- - test/schemas/good_schema_2.json
168
- - test/schemas/good_schema_extends1.json
169
- - test/schemas/good_schema_extends2.json
170
- - test/schemas/inner.schema.json
171
- - test/schemas/one_of_ref_links_schema.json
172
- - test/schemas/ref john with spaces schema.json
173
- - test/schemas/relative_definition_schema.json
174
- - test/schemas/self_link_schema.json
175
- - test/schemas/up_link_schema.json
176
- - test/test_all_of_ref_schema.rb
177
- - test/test_any_of_ref_schema.rb
178
- - test/test_bad_schema_ref.rb
179
- - test/test_common_test_suite.rb
180
- - test/test_custom_format.rb
181
- - test/test_definition.rb
182
- - test/test_extended_schema.rb
183
- - test/test_extends_and_additionalProperties.rb
184
- - test/test_files_v3.rb
185
- - test/test_fragment_resolution.rb
186
- - test/test_fragment_validation_with_ref.rb
187
- - test/test_full_validation.rb
188
- - test/test_helper.rb
189
- - test/test_initialize_data.rb
190
- - test/test_jsonschema_draft1.rb
191
- - test/test_jsonschema_draft2.rb
192
- - test/test_jsonschema_draft3.rb
193
- - test/test_jsonschema_draft4.rb
194
- - test/test_list_option.rb
195
- - test/test_load_ref_schema.rb
196
- - test/test_merge_missing_values.rb
197
- - test/test_minitems.rb
198
- - test/test_one_of.rb
199
- - test/test_ruby_schema.rb
200
- - test/test_schema_loader.rb
201
- - test/test_schema_type_attribute.rb
202
- - test/test_schema_validation.rb
203
- - test/test_stringify.rb
204
- - test/test_uri_related.rb
205
- - test/test_validator.rb
206
149
  homepage: http://github.com/ruby-json-schema/json-schema/tree/master
207
150
  licenses:
208
151
  - MIT
@@ -223,66 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
166
  version: '1.8'
224
167
  requirements: []
225
168
  rubyforge_project:
226
- rubygems_version: 2.4.5
169
+ rubygems_version: 2.4.8
227
170
  signing_key:
228
171
  specification_version: 4
229
172
  summary: Ruby JSON Schema Validator
230
- test_files:
231
- - test/test_all_of_ref_schema.rb
232
- - test/test_any_of_ref_schema.rb
233
- - test/test_bad_schema_ref.rb
234
- - test/test_common_test_suite.rb
235
- - test/test_custom_format.rb
236
- - test/test_definition.rb
237
- - test/test_extended_schema.rb
238
- - test/test_extends_and_additionalProperties.rb
239
- - test/test_files_v3.rb
240
- - test/test_fragment_resolution.rb
241
- - test/test_fragment_validation_with_ref.rb
242
- - test/test_full_validation.rb
243
- - test/test_helper.rb
244
- - test/test_initialize_data.rb
245
- - test/test_jsonschema_draft1.rb
246
- - test/test_jsonschema_draft2.rb
247
- - test/test_jsonschema_draft3.rb
248
- - test/test_jsonschema_draft4.rb
249
- - test/test_list_option.rb
250
- - test/test_load_ref_schema.rb
251
- - test/test_merge_missing_values.rb
252
- - test/test_minitems.rb
253
- - test/test_one_of.rb
254
- - test/test_ruby_schema.rb
255
- - test/test_schema_loader.rb
256
- - test/test_schema_type_attribute.rb
257
- - test/test_schema_validation.rb
258
- - test/test_stringify.rb
259
- - test/test_uri_related.rb
260
- - test/test_validator.rb
261
- - test/data/all_of_ref_data.json
262
- - test/data/any_of_ref_data.json
263
- - test/data/bad_data_1.json
264
- - test/data/good_data_1.json
265
- - test/data/one_of_ref_links_data.json
266
- - test/schemas/address_microformat.json
267
- - test/schemas/all_of_ref_base_schema.json
268
- - test/schemas/all_of_ref_schema.json
269
- - test/schemas/any_of_ref_jane_schema.json
270
- - test/schemas/any_of_ref_jimmy_schema.json
271
- - test/schemas/any_of_ref_john_schema.json
272
- - test/schemas/any_of_ref_schema.json
273
- - test/schemas/definition_schema.json
274
- - test/schemas/extends_and_additionalProperties-1-filename.schema.json
275
- - test/schemas/extends_and_additionalProperties-1-ref.schema.json
276
- - test/schemas/extends_and_additionalProperties-2-filename.schema.json
277
- - test/schemas/extends_and_additionalProperties-2-ref.schema.json
278
- - test/schemas/good_schema_1.json
279
- - test/schemas/good_schema_2.json
280
- - test/schemas/good_schema_extends1.json
281
- - test/schemas/good_schema_extends2.json
282
- - test/schemas/inner.schema.json
283
- - test/schemas/one_of_ref_links_schema.json
284
- - test/schemas/ref john with spaces schema.json
285
- - test/schemas/relative_definition_schema.json
286
- - test/schemas/self_link_schema.json
287
- - test/schemas/up_link_schema.json
288
- has_rdoc:
173
+ test_files: []
@@ -1,3 +0,0 @@
1
- {
2
- "name" : "john"
3
- }
@@ -1,7 +0,0 @@
1
- {
2
- "names" :
3
- [ "john"
4
- , "jane"
5
- , "jimmy"
6
- ]
7
- }
@@ -1,3 +0,0 @@
1
- {
2
- "a" : "poop"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "a" : 5
3
- }
@@ -1,5 +0,0 @@
1
- { "links":
2
- [{ "rel" : ["self"] , "href":"http://api.example.com/api/object/3" }
3
- ,{ "rel" : ["up"] , "href":"http://api.example.com/api/object" }
4
- ]
5
- }
@@ -1,18 +0,0 @@
1
- {
2
- "description": "An Address following the convention of http://microformats.org/wiki/hcard",
3
- "type": "object",
4
- "properties": {
5
- "post-office-box": { "type": "string" },
6
- "extended-address": { "type": "string" },
7
- "street-address": { "type": "string" },
8
- "locality":{ "type": "string" },
9
- "region": { "type": "string" },
10
- "postal-code": { "type": "string" },
11
- "country-name": { "type": "string"}
12
- },
13
- "required": ["locality", "region", "country-name"],
14
- "dependencies": {
15
- "post-office-box": "street-address",
16
- "extended-address": "street-address"
17
- }
18
- }
@@ -1,6 +0,0 @@
1
- {
2
- "type": "object",
3
- "properties" : {
4
- "name" : { "type": "integer" }
5
- }
6
- }
@@ -1,7 +0,0 @@
1
- { "$schema" : "http://json-schema.org/draft-04/schema#",
2
- "type" : "object",
3
- "allOf" :
4
- [ { "$ref" : "all_of_ref_base_schema.json" }
5
- ]
6
-
7
- }
@@ -1,4 +0,0 @@
1
- { "$schema" : "http://json-schema.org/draft-04/schema#"
2
- , "type" : "string"
3
- , "pattern" : "jane"
4
- }
@@ -1,4 +0,0 @@
1
- { "$schema" : "http://json-schema.org/draft-04/schema#"
2
- , "type" : "string"
3
- , "pattern" : "jimmy"
4
- }
@@ -1,4 +0,0 @@
1
- { "$schema" : "http://json-schema.org/draft-04/schema#"
2
- , "type" : "string"
3
- , "pattern" : "john"
4
- }
@@ -1,15 +0,0 @@
1
- { "$schema" : "http://json-schema.org/draft-04/schema#"
2
- , "type" : "object"
3
- , "properties" :
4
- { "names" :
5
- { "type" : "array"
6
- , "items" :
7
- { "anyOf" :
8
- [ { "$ref" : "any_of_ref_john_schema.json" }
9
- , { "$ref" : "any_of_ref_jane_schema.json" }
10
- , { "$ref" : "any_of_ref_jimmy_schema.json" }
11
- ]
12
- }
13
- }
14
- }
15
- }
@@ -1,15 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "description": "schema with definition",
4
- "type": "object",
5
- "properties": {
6
- "a": {
7
- "$ref": "#/definitions/foo"
8
- }
9
- },
10
- "definitions": {
11
- "foo": {
12
- "type": "integer"
13
- }
14
- }
15
- }
@@ -1,34 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-03/schema#",
3
- "type": "object",
4
- "extends": "inner.schema.json",
5
- "properties": {
6
- "outerA": {
7
- "description": "blah",
8
- "required": false,
9
- "additionalProperties": false,
10
- "properties": {
11
- "outerA1": {
12
- "type":"boolean",
13
- "required": false
14
- }
15
- }
16
- },
17
- "outerB": {
18
- "required": false,
19
- "type": "array",
20
- "minItems": 1,
21
- "maxItems": 50,
22
- "items": {
23
- "extends": "inner.schema.json",
24
- "additionalProperties": false
25
- }
26
- },
27
- "outerC": {
28
- "description": "blah",
29
- "type":"boolean",
30
- "required": false
31
- }
32
- },
33
- "additionalProperties": false
34
- }
@@ -1,34 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-03/schema#",
3
- "type": "object",
4
- "extends": {"$ref":"inner.schema.json#"},
5
- "properties": {
6
- "outerA": {
7
- "description": "blah",
8
- "required": false,
9
- "additionalProperties": false,
10
- "properties": {
11
- "outerA1": {
12
- "type":"boolean",
13
- "required": false
14
- }
15
- }
16
- },
17
- "outerB": {
18
- "required": false,
19
- "type": "array",
20
- "minItems": 1,
21
- "maxItems": 50,
22
- "items": {
23
- "extends": {"$ref":"inner.schema.json#"},
24
- "additionalProperties": false
25
- }
26
- },
27
- "outerC": {
28
- "description": "blah",
29
- "type":"boolean",
30
- "required": false
31
- }
32
- },
33
- "additionalProperties": false
34
- }