json-schema 5.2.2 → 6.0.0
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.
- checksums.yaml +4 -4
- data/lib/json-schema/attributes/additionalproperties.rb +1 -1
- data/lib/json-schema/attributes/allof.rb +2 -2
- data/lib/json-schema/attributes/anyof.rb +2 -2
- data/lib/json-schema/attributes/extends.rb +5 -3
- data/lib/json-schema/attributes/formats/custom.rb +4 -6
- data/lib/json-schema/attributes/formats/ip.rb +1 -1
- data/lib/json-schema/attributes/oneof.rb +2 -2
- data/lib/json-schema/attributes/ref.rb +13 -12
- data/lib/json-schema/attributes/required.rb +1 -1
- data/lib/json-schema/attributes/type.rb +3 -3
- data/lib/json-schema/attributes/type_v4.rb +1 -1
- data/lib/json-schema/errors/validation_error.rb +2 -2
- data/lib/json-schema/schema/reader.rb +1 -1
- data/lib/json-schema/schema.rb +3 -3
- data/lib/json-schema/util/array_set.rb +1 -3
- data/lib/json-schema/util/uri.rb +2 -2
- data/lib/json-schema/util/uuid.rb +19 -18
- data/lib/json-schema/validator.rb +28 -30
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f59422377fa48d3a101aa046e33f7d58c8e07ac60e253dd85c92cdc9f62a5f28
|
4
|
+
data.tar.gz: c77a432690bf4ddd59c34fca91b78b902ac802ded9add8dcf671505b7f423309
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0c2b651991ff80dcfffaa360b2bb63e5b223acde172ed73435ed20edc8abada0b9c351cb042b0c03f20db08aa1f5eb09a20fc4b396b7296147e5680ca60f122
|
7
|
+
data.tar.gz: 695913ca06faf062d38e8b2b10c03f62cab6343b0d8b24b5b0f2d46a9b0f671dd5dd0f70cb137236661b637740da1353d8c10383029c62f2efce91906efe7350
|
@@ -32,7 +32,7 @@ module JSON
|
|
32
32
|
diff = validation_errors(processor).count - pre_validation_error_count
|
33
33
|
|
34
34
|
while diff > 0
|
35
|
-
diff
|
35
|
+
diff -= 1
|
36
36
|
errors["allOf ##{schema_index}"].push(validation_errors(processor).pop)
|
37
37
|
end
|
38
38
|
end
|
@@ -44,7 +44,7 @@ module JSON
|
|
44
44
|
common_missing_properties = (all_property_errors.first || []).to_set
|
45
45
|
|
46
46
|
all_property_errors[1..].each do |curr_property_errors|
|
47
|
-
common_missing_properties
|
47
|
+
common_missing_properties &= curr_property_errors.to_set
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -27,7 +27,7 @@ module JSON
|
|
27
27
|
diff = validation_errors(processor).count - pre_validation_error_count
|
28
28
|
valid = false if diff > 0
|
29
29
|
while diff > 0
|
30
|
-
diff
|
30
|
+
diff -= 1
|
31
31
|
errors["anyOf ##{schema_index}"].push(validation_errors(processor).pop)
|
32
32
|
end
|
33
33
|
|
@@ -36,7 +36,7 @@ module JSON
|
|
36
36
|
data = original_data
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
unless valid
|
40
40
|
message = "The property '#{build_fragment(fragments)}' of type #{type_of_data(data)} did not match one or more of the required schemas"
|
41
41
|
validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
|
42
42
|
validation_errors(processor).last.sub_errors = errors
|
@@ -6,7 +6,7 @@ module JSON
|
|
6
6
|
class ExtendsAttribute < Attribute
|
7
7
|
def self.validate(current_schema, data, fragments, processor, validator, options = {})
|
8
8
|
schemas = current_schema.schema['extends']
|
9
|
-
schemas = [schemas]
|
9
|
+
schemas = [schemas] unless schemas.is_a?(Array)
|
10
10
|
schemas.each do |s|
|
11
11
|
uri, schema = get_extended_uri_and_schema(s, current_schema, validator)
|
12
12
|
if schema
|
@@ -22,7 +22,8 @@ module JSON
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.get_extended_uri_and_schema(s, current_schema, validator)
|
25
|
-
uri
|
25
|
+
uri = nil
|
26
|
+
schema = nil
|
26
27
|
|
27
28
|
if s.is_a?(Hash)
|
28
29
|
uri = current_schema.uri
|
@@ -30,7 +31,8 @@ module JSON
|
|
30
31
|
ref_uri, ref_schema = JSON::Schema::RefAttribute.get_referenced_uri_and_schema(s, current_schema, validator)
|
31
32
|
if ref_schema
|
32
33
|
if s.size == 1 # Check if anything else apart from $ref
|
33
|
-
uri
|
34
|
+
uri = ref_uri
|
35
|
+
schema = ref_schema
|
34
36
|
else
|
35
37
|
s = s.dup
|
36
38
|
s.delete '$ref'
|
@@ -9,12 +9,10 @@ module JSON
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def validate(current_schema, data, fragments, processor, _validator, options = {})
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
self.class.validation_error(processor, message, fragments, current_schema, self.class, options[:record_errors])
|
17
|
-
end
|
12
|
+
@validation_proc.call data
|
13
|
+
rescue JSON::Schema::CustomFormatError => e
|
14
|
+
message = "The property '#{self.class.build_fragment(fragments)}' #{e.message}"
|
15
|
+
self.class.validation_error(processor, message, fragments, current_schema, self.class, options[:record_errors])
|
18
16
|
end
|
19
17
|
end
|
20
18
|
end
|
@@ -14,7 +14,7 @@ module JSON
|
|
14
14
|
raise e unless e.message.start_with?('invalid address')
|
15
15
|
end
|
16
16
|
|
17
|
-
family = ip_version == 6 ? Socket::AF_INET6 : Socket::AF_INET
|
17
|
+
family = (ip_version == 6) ? Socket::AF_INET6 : Socket::AF_INET
|
18
18
|
unless ip && ip.family == family
|
19
19
|
error_message = "The property '#{build_fragment(fragments)}' must be a valid IPv#{ip_version} address"
|
20
20
|
validation_error(processor, error_message, fragments, current_schema, self, options[:record_errors])
|
@@ -27,9 +27,9 @@ module JSON
|
|
27
27
|
|
28
28
|
diff = validation_errors(processor).count - pre_validation_error_count
|
29
29
|
valid = false if diff > 0
|
30
|
-
validation_error_count += 1
|
30
|
+
validation_error_count += 1 unless valid
|
31
31
|
while diff > 0
|
32
|
-
diff
|
32
|
+
diff -= 1
|
33
33
|
errors["oneOf ##{schema_index}"].push(validation_errors(processor).pop)
|
34
34
|
end
|
35
35
|
data = original_data
|
@@ -20,7 +20,8 @@ module JSON
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.get_referenced_uri_and_schema(s, current_schema, validator)
|
23
|
-
uri
|
23
|
+
uri = nil
|
24
|
+
schema = nil
|
24
25
|
|
25
26
|
temp_uri = JSON::Util::URI.normalize_ref(s['$ref'], current_schema.uri)
|
26
27
|
|
@@ -35,17 +36,17 @@ module JSON
|
|
35
36
|
fragments = JSON::Util::URI.parse(JSON::Util::URI.unescape_uri(temp_uri)).fragment.split('/')
|
36
37
|
fragment_path = ''
|
37
38
|
fragments.each do |fragment|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
39
|
+
next unless fragment && fragment != ''
|
40
|
+
|
41
|
+
fragment = fragment.gsub('~0', '~').gsub('~1', '/')
|
42
|
+
target_schema = if target_schema.is_a?(Array)
|
43
|
+
target_schema[fragment.to_i]
|
44
|
+
else
|
45
|
+
target_schema[fragment]
|
46
|
+
end
|
47
|
+
fragment_path += "/#{fragment}"
|
48
|
+
if target_schema.nil?
|
49
|
+
raise SchemaError, "The fragment '#{fragment_path}' does not exist on schema #{ref_schema.uri}"
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -18,7 +18,7 @@ module JSON
|
|
18
18
|
!defined_properties[property]['default'].nil? &&
|
19
19
|
!defined_properties[property]['readonly']
|
20
20
|
|
21
|
-
|
21
|
+
unless prop_defaults
|
22
22
|
message = "The property '#{build_fragment(fragments)}' did not contain a required property of '#{property}'"
|
23
23
|
validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
|
24
24
|
end
|
@@ -11,7 +11,7 @@ module JSON
|
|
11
11
|
current_schema.schema['type']
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
unless types.is_a?(Array)
|
15
15
|
types = [types]
|
16
16
|
union = false
|
17
17
|
end
|
@@ -41,7 +41,7 @@ module JSON
|
|
41
41
|
diff = validation_errors(processor).count - pre_validation_error_count
|
42
42
|
valid = false if diff > 0
|
43
43
|
while diff > 0
|
44
|
-
diff
|
44
|
+
diff -= 1
|
45
45
|
union_errors["type ##{type_index}"].push(validation_errors(processor).pop)
|
46
46
|
end
|
47
47
|
end
|
@@ -50,7 +50,7 @@ module JSON
|
|
50
50
|
end
|
51
51
|
|
52
52
|
if options[:disallow]
|
53
|
-
return
|
53
|
+
return unless valid
|
54
54
|
|
55
55
|
message = "The property '#{build_fragment(fragments)}' matched one or more of the following types: #{list_types(types)}"
|
56
56
|
validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
|
@@ -16,7 +16,7 @@ module JSON
|
|
16
16
|
|
17
17
|
def to_string(subschema_level = 0)
|
18
18
|
if @sub_errors.empty?
|
19
|
-
subschema_level == 0 ? message_with_schema : message
|
19
|
+
(subschema_level == 0) ? message_with_schema : message
|
20
20
|
else
|
21
21
|
messages = ["#{message}. The schema specific errors were:\n"]
|
22
22
|
@sub_errors.each do |subschema, errors|
|
@@ -29,7 +29,7 @@ module JSON
|
|
29
29
|
|
30
30
|
def to_hash
|
31
31
|
base = { schema: @schema.uri, fragment: ::JSON::Schema::Attribute.build_fragment(fragments), message: message_with_schema, failed_attribute: @failed_attribute.to_s.split(':').last.split('Attribute').first }
|
32
|
-
|
32
|
+
unless @sub_errors.empty?
|
33
33
|
base[:errors] = @sub_errors.each_with_object({}) do |(subschema, errors), hsh|
|
34
34
|
subschema_sym = subschema.downcase.gsub(/\W+/, '_').to_sym
|
35
35
|
hsh[subschema_sym] = Array(errors).map { |e| e.to_hash }
|
data/lib/json-schema/schema.rb
CHANGED
@@ -34,13 +34,13 @@ module JSON
|
|
34
34
|
|
35
35
|
def self.stringify(schema)
|
36
36
|
case schema
|
37
|
-
when Hash
|
37
|
+
when Hash
|
38
38
|
schema.map { |key, _value| [key.to_s, stringify(schema[key])] }.to_h
|
39
|
-
when Array
|
39
|
+
when Array
|
40
40
|
schema.map do |schema_item|
|
41
41
|
stringify(schema_item)
|
42
42
|
end
|
43
|
-
when Symbol
|
43
|
+
when Symbol
|
44
44
|
schema.to_s
|
45
45
|
else
|
46
46
|
schema
|
@@ -1,11 +1,9 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
1
|
# This is a hack that I don't want to ever use anywhere else or repeat EVER, but we need enums to be
|
4
2
|
# an Array to pass schema validation. But we also want fast lookup!
|
5
3
|
|
6
4
|
class ArraySet < Array
|
7
5
|
def include?(obj)
|
8
|
-
|
6
|
+
unless defined? @values
|
9
7
|
@values = Set.new
|
10
8
|
each { |x| @values << convert_to_float_if_numeric(x) }
|
11
9
|
end
|
data/lib/json-schema/util/uri.rb
CHANGED
@@ -6,7 +6,7 @@ module JSON
|
|
6
6
|
module Util
|
7
7
|
# @api private
|
8
8
|
class URI < Addressable::URI
|
9
|
-
SUPPORTED_PROTOCOLS = %w
|
9
|
+
SUPPORTED_PROTOCOLS = %w[http https ftp tftp sftp ssh svn+ssh telnet nntp gopher wais ldap prospero]
|
10
10
|
|
11
11
|
class << self
|
12
12
|
alias unescape_uri unescape
|
@@ -14,7 +14,7 @@ module JSON
|
|
14
14
|
# @param uri [String, Addressable::URI]
|
15
15
|
# @return [Addressable::URI, nil]
|
16
16
|
def parse(uri)
|
17
|
-
super
|
17
|
+
super
|
18
18
|
rescue Addressable::URI::InvalidURIError => e
|
19
19
|
raise JSON::Schema::UriError, e.message
|
20
20
|
end
|
@@ -36,7 +36,7 @@ module JSON
|
|
36
36
|
private_class_method :new
|
37
37
|
|
38
38
|
class << self
|
39
|
-
def mask
|
39
|
+
def mask(v, str)
|
40
40
|
nstr = str.bytes.to_a
|
41
41
|
version = [0, 16, 32, 48, 64, 80][v]
|
42
42
|
nstr[6] &= 0b00001111
|
@@ -54,7 +54,7 @@ module JSON
|
|
54
54
|
|
55
55
|
# UUID generation using SHA1. Recommended over create_md5.
|
56
56
|
# Namespace object is another UUID, some of them are pre-defined below.
|
57
|
-
def create_sha1
|
57
|
+
def create_sha1(str, namespace)
|
58
58
|
sha1 = Digest::SHA1.new
|
59
59
|
sha1.update namespace.raw_bytes
|
60
60
|
sha1.update str
|
@@ -67,7 +67,7 @@ module JSON
|
|
67
67
|
alias create_v5 create_sha1
|
68
68
|
|
69
69
|
# UUID generation using MD5 (for backward compat.)
|
70
|
-
def create_md5
|
70
|
+
def create_md5(str, namespace)
|
71
71
|
md5 = Digest::MD5.new
|
72
72
|
md5.update namespace.raw_bytes
|
73
73
|
md5.update str
|
@@ -96,12 +96,12 @@ module JSON
|
|
96
96
|
end
|
97
97
|
alias create_v4 create_random
|
98
98
|
|
99
|
-
def read_state
|
99
|
+
def read_state(fp) # :nodoc:
|
100
100
|
fp.rewind
|
101
101
|
Marshal.load fp.read
|
102
102
|
end
|
103
103
|
|
104
|
-
def write_state
|
104
|
+
def write_state(fp, c, m) # :nodoc:
|
105
105
|
fp.rewind
|
106
106
|
str = Marshal.dump [c, m]
|
107
107
|
fp.write str
|
@@ -117,10 +117,10 @@ module JSON
|
|
117
117
|
# invokation. If you want to speed this up, try remounting tmpdir with a
|
118
118
|
# memory based filesystem (such as tmpfs). STILL slow? then no way but
|
119
119
|
# rewrite it with c :)
|
120
|
-
def create
|
120
|
+
def create(clock = nil, time = nil, mac_addr = nil)
|
121
121
|
c = t = m = nil
|
122
122
|
Dir.chdir Dir.tmpdir do
|
123
|
-
unless FileTest.exist? STATE_FILE
|
123
|
+
unless FileTest.exist? STATE_FILE
|
124
124
|
# Generate a pseudo MAC address because we have no pure-ruby way
|
125
125
|
# to know the MAC address of the NIC this system uses. Note
|
126
126
|
# that cheating with pseudo arresses here is completely legal:
|
@@ -150,10 +150,10 @@ module JSON
|
|
150
150
|
c = clock % 0x4000 if clock
|
151
151
|
m = mac_addr if mac_addr
|
152
152
|
t = time
|
153
|
-
if t.nil?
|
153
|
+
if t.nil?
|
154
154
|
# UUID epoch is 1582/Oct/15
|
155
155
|
tt = Time.now
|
156
|
-
t = (tt.to_i *
|
156
|
+
t = (tt.to_i * 10_000_000) + (tt.tv_usec * 10) + 0x01B21DD213814000
|
157
157
|
end
|
158
158
|
c = c.succ # important; increment here
|
159
159
|
write_state fp, c, m
|
@@ -162,21 +162,21 @@ module JSON
|
|
162
162
|
|
163
163
|
tl = t & 0xFFFF_FFFF
|
164
164
|
tm = t >> 32
|
165
|
-
tm
|
165
|
+
tm &= 0xFFFF
|
166
166
|
th = t >> 48
|
167
|
-
th
|
168
|
-
th
|
167
|
+
th &= 0x0FFF
|
168
|
+
th |= 0x1000
|
169
169
|
cl = c & 0xFF
|
170
170
|
ch = c & 0x3F00
|
171
|
-
ch
|
172
|
-
ch
|
171
|
+
ch >>= 8
|
172
|
+
ch |= 0x80
|
173
173
|
pack tl, tm, th, cl, ch, m
|
174
174
|
end
|
175
175
|
alias create_v1 create
|
176
176
|
|
177
177
|
# A simple GUID parser: just ignores unknown characters and convert
|
178
178
|
# hexadecimal dump into 16-octet object.
|
179
|
-
def parse
|
179
|
+
def parse(obj)
|
180
180
|
str = obj.to_s.sub(/\Aurn:uuid:/, '')
|
181
181
|
str.gsub!(/[^0-9A-Fa-f]/, '')
|
182
182
|
raw = str[0..31].lines.to_a.pack 'H*'
|
@@ -187,7 +187,7 @@ module JSON
|
|
187
187
|
|
188
188
|
# The 'primitive constructor' of this class
|
189
189
|
# Note UUID.pack(uuid.unpack) == uuid
|
190
|
-
def pack
|
190
|
+
def pack(tl, tm, th, ch, cl, n)
|
191
191
|
raw = [tl, tm, th, ch, cl, n].pack 'NnnCCa6'
|
192
192
|
ret = new raw
|
193
193
|
ret.freeze
|
@@ -238,13 +238,14 @@ module JSON
|
|
238
238
|
# Two UUIDs are said to be equal if and only if their (byte-order
|
239
239
|
# canonicalized) integer representations are equivalent. Refer RFC4122 for
|
240
240
|
# details.
|
241
|
-
def ==
|
241
|
+
def ==(other)
|
242
242
|
to_i == other.to_i
|
243
243
|
end
|
244
244
|
|
245
245
|
include Comparable
|
246
|
+
|
246
247
|
# UUIDs are comparable (don't know what benefits are there, though).
|
247
|
-
def <=>
|
248
|
+
def <=>(other)
|
248
249
|
to_s <=> other.to_s
|
249
250
|
end
|
250
251
|
|
@@ -188,11 +188,11 @@ module JSON
|
|
188
188
|
|
189
189
|
# Check for schemas in union types
|
190
190
|
%w[type disallow].each do |key|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
191
|
+
next unless schema[key].is_a?(Array)
|
192
|
+
|
193
|
+
schema[key].each do |type|
|
194
|
+
if type.is_a?(Hash)
|
195
|
+
handle_schema(parent_schema, type)
|
196
196
|
end
|
197
197
|
end
|
198
198
|
end
|
@@ -253,11 +253,9 @@ module JSON
|
|
253
253
|
|
254
254
|
class << self
|
255
255
|
def validate(schema, data, opts = {})
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
false
|
260
|
-
end
|
256
|
+
validate!(schema, data, opts)
|
257
|
+
rescue JSON::Schema::ValidationError, JSON::Schema::SchemaError
|
258
|
+
false
|
261
259
|
end
|
262
260
|
|
263
261
|
def validate_json(schema, data, opts = {})
|
@@ -341,7 +339,7 @@ module JSON
|
|
341
339
|
|
342
340
|
def cache_schemas=(val)
|
343
341
|
warn '[DEPRECATION NOTICE] Schema caching is now a validation option. Schemas will still be cached if this is set to true, but this method will be removed in version >= 3. Please use the :clear_cache validation option instead.'
|
344
|
-
@@cache_schemas = val == true
|
342
|
+
@@cache_schemas = val == true
|
345
343
|
end
|
346
344
|
|
347
345
|
def validators
|
@@ -423,7 +421,7 @@ module JSON
|
|
423
421
|
|
424
422
|
def json_backend=(backend)
|
425
423
|
if defined?(MultiJson)
|
426
|
-
backend = backend == 'json'
|
424
|
+
backend = 'json_gem' if backend == 'json'
|
427
425
|
MultiJson.respond_to?(:use) ? MultiJson.use(backend) : MultiJson.engine = backend
|
428
426
|
else
|
429
427
|
backend = backend.to_s
|
@@ -483,7 +481,7 @@ module JSON
|
|
483
481
|
end
|
484
482
|
end
|
485
483
|
|
486
|
-
|
484
|
+
unless defined?(MultiJson)
|
487
485
|
if Gem::Specification.find_all_by_name('json').any?
|
488
486
|
require 'json'
|
489
487
|
@@available_json_backends << 'json'
|
@@ -505,11 +503,11 @@ module JSON
|
|
505
503
|
end
|
506
504
|
|
507
505
|
@@serializer = if @@json_backend == 'yajl'
|
508
|
-
|
506
|
+
->(o) { Yajl::Encoder.encode(o) }
|
509
507
|
elsif @@json_backend == 'json'
|
510
|
-
|
508
|
+
->(o) { JSON.dump(o) }
|
511
509
|
else
|
512
|
-
|
510
|
+
->(o) { YAML.dump(o) }
|
513
511
|
end
|
514
512
|
end
|
515
513
|
end
|
@@ -518,13 +516,13 @@ module JSON
|
|
518
516
|
|
519
517
|
if Gem::Specification.find_all_by_name('uuidtools').any?
|
520
518
|
require 'uuidtools'
|
521
|
-
@@fake_uuid_generator =
|
519
|
+
@@fake_uuid_generator = ->(s) { UUIDTools::UUID.sha1_create(UUIDTools::UUID_URL_NAMESPACE, s).to_s }
|
522
520
|
else
|
523
521
|
require 'json-schema/util/uuid'
|
524
|
-
@@fake_uuid_generator =
|
522
|
+
@@fake_uuid_generator = ->(s) { JSON::Util::UUID.create_v5(s, JSON::Util::UUID::Nil).to_s }
|
525
523
|
end
|
526
524
|
|
527
|
-
def serialize
|
525
|
+
def serialize(schema)
|
528
526
|
if defined?(MultiJson)
|
529
527
|
MultiJson.respond_to?(:dump) ? MultiJson.dump(schema) : MultiJson.encode(schema)
|
530
528
|
else
|
@@ -532,7 +530,7 @@ module JSON
|
|
532
530
|
end
|
533
531
|
end
|
534
532
|
|
535
|
-
def fake_uuid
|
533
|
+
def fake_uuid(schema)
|
536
534
|
@@fake_uuid_generator.call(schema)
|
537
535
|
end
|
538
536
|
|
@@ -549,7 +547,15 @@ module JSON
|
|
549
547
|
rescue JSON::Schema::JsonParseError
|
550
548
|
# Build a uri for it
|
551
549
|
schema_uri = Util::URI.normalized_uri(schema)
|
552
|
-
if
|
550
|
+
if self.class.schema_loaded?(schema_uri)
|
551
|
+
schema = self.class.schema_for_uri(schema_uri)
|
552
|
+
if @options[:list] && @options[:fragment].nil?
|
553
|
+
schema = schema.to_array_schema
|
554
|
+
schema.uri = JSON::Util::URI.parse(fake_uuid(serialize(schema.schema)))
|
555
|
+
self.class.add_schema(schema)
|
556
|
+
end
|
557
|
+
schema
|
558
|
+
else
|
553
559
|
schema = @options[:schema_reader].read(schema_uri)
|
554
560
|
schema = JSON::Schema.stringify(schema)
|
555
561
|
|
@@ -558,14 +564,6 @@ module JSON
|
|
558
564
|
end
|
559
565
|
|
560
566
|
self.class.add_schema(schema)
|
561
|
-
else
|
562
|
-
schema = self.class.schema_for_uri(schema_uri)
|
563
|
-
if @options[:list] && @options[:fragment].nil?
|
564
|
-
schema = schema.to_array_schema
|
565
|
-
schema.uri = JSON::Util::URI.parse(fake_uuid(serialize(schema.schema)))
|
566
|
-
self.class.add_schema(schema)
|
567
|
-
end
|
568
|
-
schema
|
569
567
|
end
|
570
568
|
end
|
571
569
|
elsif schema.is_a?(Hash)
|
@@ -594,7 +592,7 @@ module JSON
|
|
594
592
|
begin
|
595
593
|
# Check if the string is valid integer
|
596
594
|
strict_convert = data.match?(/\A[+-]?\d+\z/) && !@options[:parse_integer]
|
597
|
-
data =
|
595
|
+
data = self.class.parse(data) unless strict_convert
|
598
596
|
rescue JSON::Schema::JsonParseError
|
599
597
|
begin
|
600
598
|
json_uri = Util::URI.normalized_uri(data)
|
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:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenny Hoxworth
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 4.2.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 4.2.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: webmock
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,7 +199,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
199
|
requirements:
|
200
200
|
- - ">="
|
201
201
|
- !ruby/object:Gem::Version
|
202
|
-
version: '2
|
202
|
+
version: '3.2'
|
203
203
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
204
|
requirements:
|
205
205
|
- - ">="
|