json-schema 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.textile CHANGED
@@ -22,7 +22,7 @@ From the git repo:
22
22
 
23
23
  <pre>
24
24
  $ gem build json-schema.gemspec
25
- $ gem install json-schema-2.0.1.gem
25
+ $ gem install json-schema-2.0.2.gem
26
26
  </pre>
27
27
 
28
28
 
@@ -3,10 +3,10 @@ module JSON
3
3
  class MaxItemsAttribute < Attribute
4
4
  def self.validate(current_schema, data, fragments, processor, validator, options = {})
5
5
  if data.is_a?(Array) && (data.compact.size > current_schema.schema['maxItems'])
6
- message = "The property '#{build_fragment(fragments)}' did not contain a minimum number of items #{current_schema.schema['minItems']}"
6
+ message = "The property '#{build_fragment(fragments)}' had more items than the allowed #{current_schema.schema['maxItems']}"
7
7
  validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
8
8
  end
9
9
  end
10
10
  end
11
11
  end
12
- end
12
+ end
@@ -233,8 +233,14 @@ module JSON
233
233
  if parent_schema.schema["$ref"]
234
234
  load_ref_schema(parent_schema, parent_schema.schema["$ref"])
235
235
  end
236
- if parent_schema.schema["extends"] && parent_schema.schema["extends"].is_a?(String)
237
- load_ref_schema(parent_schema, parent_schema.schema["extends"])
236
+ if parent_schema.schema["extends"]
237
+ if parent_schema.schema["extends"].is_a?(String)
238
+ load_ref_schema(parent_schema, parent_schema.schema["extends"])
239
+ elsif parent_schema.schema["extends"].is_a?(Array)
240
+ parent_schema.schema["extends"].each do |type|
241
+ handle_schema(parent_schema, type)
242
+ end
243
+ end
238
244
  end
239
245
 
240
246
  # Check for schemas in union types
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema" : "http://json-schema.org/draft-03/schema#",
3
+ "type" : "object",
4
+ "extends": {"$ref": "good_schema_1.json"},
5
+ "properties" : {
6
+ "c" : {
7
+ "required" : false
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema" : "http://json-schema.org/draft-03/schema#",
3
+ "type" : "object",
4
+ "extends": [
5
+ {"$ref": "good_schema_1.json"},
6
+ {"$ref": "good_schema_2.json"}
7
+ ],
8
+ "properties" : {
9
+ "c" : {
10
+ "required" : false
11
+ }
12
+ }
13
+ }
@@ -40,4 +40,13 @@ class JSONSchemaTest < Test::Unit::TestCase
40
40
  data = {"b" => {"a" => "boo"}}
41
41
  assert(!JSON::Validator.validate(File.join(File.dirname(__FILE__),"schemas/good_schema_1.json"),data))
42
42
  end
43
+
44
+ def test_file_extends
45
+ data = {"a" => 5}
46
+ assert(JSON::Validator.validate(File.join(File.dirname(__FILE__),"schemas/good_schema_extends1.json"),data))
47
+
48
+ data = {"a" => 5, "b" => {"a" => 5}}
49
+ assert(JSON::Validator.validate(File.join(File.dirname(__FILE__),"schemas/good_schema_extends2.json"),data))
50
+ end
51
+
43
52
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json-schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-25 00:00:00.000000000 Z
12
+ date: 2013-06-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: hoxworth@gmail.com
@@ -87,6 +87,8 @@ files:
87
87
  - test/schemas/extends_and_additionalProperties-2-ref.schema.json
88
88
  - test/schemas/good_schema_1.json
89
89
  - test/schemas/good_schema_2.json
90
+ - test/schemas/good_schema_extends1.json
91
+ - test/schemas/good_schema_extends2.json
90
92
  - test/schemas/inner.schema.json
91
93
  homepage: http://github.com/hoxworth/json-schema/tree/master
92
94
  licenses: []
@@ -130,4 +132,6 @@ test_files:
130
132
  - test/schemas/extends_and_additionalProperties-2-ref.schema.json
131
133
  - test/schemas/good_schema_1.json
132
134
  - test/schemas/good_schema_2.json
135
+ - test/schemas/good_schema_extends1.json
136
+ - test/schemas/good_schema_extends2.json
133
137
  - test/schemas/inner.schema.json