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
@@ -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)}'
|
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"]
|
237
|
-
|
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
|
data/test/test_files_v3.rb
CHANGED
@@ -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.
|
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-
|
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
|