json-schema 2.2.3 → 2.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.textile +3 -1
- data/lib/json-schema/validator.rb +7 -0
- data/test/test_list_option.rb +22 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTFiZGMyMzcwNTE3MmZlNzliZjQ1MTZkOGY5NjcxMGM4NjhhNjZkYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Yzc3NTEwMjg3MzdlOGJkOTJlNWVmMGQzYjFhMjRhNzZjZjY3NzI3Mg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTk3ZjM3YWY4MTExOGI0OGFlOTdhNjc0Y2U1YjdiNzBhNzJiNzM4NjcyMjM4
|
10
|
+
NDcwOGM4ZWMxOTgyM2U0NjY4MGZjMmYyMmQ2MDAyZDg4NzdjY2RjZWE0YmY5
|
11
|
+
MjJlMjk0MGJlNmViM2VjOGU1NDAxNWYzZWVhMTNkOWIzOTdhZWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGExNmQzMDMxZWVjODhiZWQxMzY1MTZkOWZkMjU0ZDczZGY0ZDA3MjMxYzE2
|
14
|
+
MDNiNDZkOTg5ZDE3ZmZlNTQxMjQwNTQ5ZmQ2ODUyOWEwNDg1YTFmNTUyMmFk
|
15
|
+
N2Y3NzE2NzE2YzA5Y2Y5MDg3N2I1NDBlNTM5YjJmMDcyNDNiMTI=
|
data/README.textile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
!https://travis-ci.org/hoxworth/json-schema.svg?branch=master!:https://travis-ci.org/hoxworth/json-schema
|
2
|
+
|
1
3
|
h1. Ruby JSON Schema Validator
|
2
4
|
|
3
5
|
This library is intended to provide Ruby with an interface for validating JSON objects against a JSON schema conforming to "JSON Schema Draft 4":http://tools.ietf.org/html/draft-zyp-json-schema-04. Legacy support for "JSON Schema Draft 3":http://tools.ietf.org/html/draft-zyp-json-schema-03, "JSON Schema Draft 2":http://tools.ietf.org/html/draft-zyp-json-schema-02, and "JSON Schema Draft 1":http://tools.ietf.org/html/draft-zyp-json-schema-01 is also included.
|
@@ -22,7 +24,7 @@ From the git repo:
|
|
22
24
|
|
23
25
|
<pre>
|
24
26
|
$ gem build json-schema.gemspec
|
25
|
-
$ gem install json-schema-2.2.
|
27
|
+
$ gem install json-schema-2.2.4.gem
|
26
28
|
</pre>
|
27
29
|
|
28
30
|
|
@@ -609,6 +609,13 @@ module JSON
|
|
609
609
|
Validator.add_schema(schema)
|
610
610
|
else
|
611
611
|
schema = Validator.schemas[schema_uri.to_s]
|
612
|
+
if @options[:list] && @options[:fragment].nil?
|
613
|
+
schema = schema_to_list(schema.schema)
|
614
|
+
schema_uri = URI.parse(fake_uri(serialize(schema)))
|
615
|
+
schema = JSON::Schema.new(schema, schema_uri, @options[:version])
|
616
|
+
Validator.add_schema(schema)
|
617
|
+
end
|
618
|
+
schema
|
612
619
|
end
|
613
620
|
end
|
614
621
|
elsif schema.is_a?(Hash)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.dirname(__FILE__) + '/../lib/json-schema'
|
3
|
+
|
4
|
+
class ListOptionTest < Test::Unit::TestCase
|
5
|
+
def test_list_option_reusing_schemas
|
6
|
+
schema_hash = {
|
7
|
+
"$schema" => "http://json-schema.org/draft-04/schema#",
|
8
|
+
"type" => "object",
|
9
|
+
"properties" => { "a" => { "type" => "integer" } }
|
10
|
+
}
|
11
|
+
|
12
|
+
uri = URI.parse('http://example.com/item')
|
13
|
+
schema = JSON::Schema.new(schema_hash, uri)
|
14
|
+
JSON::Validator.add_schema(schema)
|
15
|
+
|
16
|
+
data = {"a" => 1}
|
17
|
+
assert(JSON::Validator.validate(uri.to_s, data))
|
18
|
+
|
19
|
+
data = [{"a" => 1}]
|
20
|
+
assert(JSON::Validator.validate(uri.to_s, data, :list => true))
|
21
|
+
end
|
22
|
+
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.2.
|
4
|
+
version: 2.2.4
|
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-07-
|
11
|
+
date: 2014-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: hoxworth@gmail.com
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- test/test_jsonschema_draft2.rb
|
84
84
|
- test/test_jsonschema_draft3.rb
|
85
85
|
- test/test_jsonschema_draft4.rb
|
86
|
+
- test/test_list_option.rb
|
86
87
|
- test/test_one_of.rb
|
87
88
|
- test/test_ruby_schema.rb
|
88
89
|
- test/test_schema_type_attribute.rb
|
@@ -147,6 +148,7 @@ test_files:
|
|
147
148
|
- test/test_jsonschema_draft2.rb
|
148
149
|
- test/test_jsonschema_draft3.rb
|
149
150
|
- test/test_jsonschema_draft4.rb
|
151
|
+
- test/test_list_option.rb
|
150
152
|
- test/test_one_of.rb
|
151
153
|
- test/test_ruby_schema.rb
|
152
154
|
- test/test_schema_type_attribute.rb
|