json-schema 2.1.2 → 2.1.3
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 +1 -1
- data/lib/json-schema/validator.rb +9 -0
- data/test/data/any_of_ref_data.json +7 -0
- data/test/schemas/any_of_ref_jane_schema.json +4 -0
- data/test/schemas/any_of_ref_jimmy_schema.json +4 -0
- data/test/schemas/any_of_ref_john_schema.json +4 -0
- data/test/schemas/any_of_ref_schema.json +15 -0
- data/test/test_any_of_ref_schema.rb +11 -0
- metadata +14 -2
data/README.textile
CHANGED
@@ -277,6 +277,15 @@ module JSON
|
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
280
|
+
# handle validations that always contain schemas
|
281
|
+
["allOf", "anyOf", "oneOf", "not"].each do |key|
|
282
|
+
if parent_schema.schema.has_key?(key)
|
283
|
+
validations = parent_schema.schema[key]
|
284
|
+
validations = [validations] unless validations.is_a?(Array)
|
285
|
+
validations.each {|v| handle_schema(parent_schema, v) }
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
280
289
|
# Check for schemas in union types
|
281
290
|
["type", "disallow"].each do |key|
|
282
291
|
if parent_schema.schema[key] && parent_schema.schema[key].is_a?(Array)
|
@@ -0,0 +1,15 @@
|
|
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
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.dirname(__FILE__) + '/../lib/json-schema'
|
3
|
+
|
4
|
+
class AnyOfRefSchemaTest < Test::Unit::TestCase
|
5
|
+
def test_all_of_ref_schema
|
6
|
+
schema = File.join(File.dirname(__FILE__),"schemas/any_of_ref_schema.json")
|
7
|
+
data = File.join(File.dirname(__FILE__),"data/any_of_ref_data.json")
|
8
|
+
errors = JSON::Validator.fully_validate(schema,data, :errors_as_objects => true)
|
9
|
+
assert(errors.empty?, errors.map{|e| e[:message] }.join("\n"))
|
10
|
+
end
|
11
|
+
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.1.
|
4
|
+
version: 2.1.3
|
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-
|
12
|
+
date: 2013-08-02 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: hoxworth@gmail.com
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- README.textile
|
72
72
|
- LICENSE.md
|
73
73
|
- test/schemas/test_fragment_resolution.rb
|
74
|
+
- test/test_any_of_ref_schema.rb
|
74
75
|
- test/test_extended_schema.rb
|
75
76
|
- test/test_extends_and_additionalProperties.rb
|
76
77
|
- test/test_files_v3.rb
|
@@ -82,8 +83,13 @@ files:
|
|
82
83
|
- test/test_ruby_schema.rb
|
83
84
|
- test/test_schema_type_attribute.rb
|
84
85
|
- test/test_schema_validation.rb
|
86
|
+
- test/data/any_of_ref_data.json
|
85
87
|
- test/data/bad_data_1.json
|
86
88
|
- test/data/good_data_1.json
|
89
|
+
- test/schemas/any_of_ref_jane_schema.json
|
90
|
+
- test/schemas/any_of_ref_jimmy_schema.json
|
91
|
+
- test/schemas/any_of_ref_john_schema.json
|
92
|
+
- test/schemas/any_of_ref_schema.json
|
87
93
|
- test/schemas/extends_and_additionalProperties-1-filename.schema.json
|
88
94
|
- test/schemas/extends_and_additionalProperties-1-ref.schema.json
|
89
95
|
- test/schemas/extends_and_additionalProperties-2-filename.schema.json
|
@@ -119,6 +125,7 @@ specification_version: 3
|
|
119
125
|
summary: Ruby JSON Schema Validator
|
120
126
|
test_files:
|
121
127
|
- test/schemas/test_fragment_resolution.rb
|
128
|
+
- test/test_any_of_ref_schema.rb
|
122
129
|
- test/test_extended_schema.rb
|
123
130
|
- test/test_extends_and_additionalProperties.rb
|
124
131
|
- test/test_files_v3.rb
|
@@ -130,8 +137,13 @@ test_files:
|
|
130
137
|
- test/test_ruby_schema.rb
|
131
138
|
- test/test_schema_type_attribute.rb
|
132
139
|
- test/test_schema_validation.rb
|
140
|
+
- test/data/any_of_ref_data.json
|
133
141
|
- test/data/bad_data_1.json
|
134
142
|
- test/data/good_data_1.json
|
143
|
+
- test/schemas/any_of_ref_jane_schema.json
|
144
|
+
- test/schemas/any_of_ref_jimmy_schema.json
|
145
|
+
- test/schemas/any_of_ref_john_schema.json
|
146
|
+
- test/schemas/any_of_ref_schema.json
|
135
147
|
- test/schemas/extends_and_additionalProperties-1-filename.schema.json
|
136
148
|
- test/schemas/extends_and_additionalProperties-1-ref.schema.json
|
137
149
|
- test/schemas/extends_and_additionalProperties-2-filename.schema.json
|