json-schema 5.0.0 → 5.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c42ecb537bfb46692249a301cd3c0f6d8ad0a37588d572e2daaa7591a172bb5a
4
- data.tar.gz: 304974463c21a8e456099e10b37dee2ab2f0936cea8f1a34b06143da0e1d84d0
3
+ metadata.gz: 587d858bd0a07e4f6ccaafcfa72f6e04f5d69ec6f88c896cc17a40636d41fd47
4
+ data.tar.gz: 15ed642114d63e81992eaff0720371981b5a43e4152a3ca4fef93652b1586bcb
5
5
  SHA512:
6
- metadata.gz: eb9b26e1e7251258d4af08666bad83904a362239f2dabecf4aaec3b3280a6d17d9aa7285faa47e84fa854504fe75b21a2a7ac607381bd047113ea1041fdef1ba
7
- data.tar.gz: b17404fd2a367a562995aadb9882d3527098168a9e1689d2b231bf4f8e7b59b79aeba79f8525ceadffcd7fbe3d9a87297d23b7f6854f7c8fde29b59cda9867c0
6
+ metadata.gz: 9ae1e642791369ea1011118401f29821e72ade1b2869fce6e946d9cab5c08f54c8d490488688376c124c34ade88c754e3f5644f0ff74ed5b4ea5e5507f9626ee
7
+ data.tar.gz: 28739dcfe2a34db2ec171e700b5f8bcdd251c19106ca48a4e4b0c2ec8fe7684ff0ec464c883c0e9a1d7de39542ae189ed4b67fa6a73933feb0c5edb5498d3899
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Ruby JSON Schema Validator
2
2
 
3
- [![License](https://img.shields.io/github/license/voxpupuli/json-schema.svg)](https://github.com/voxpupuli/json-schema/blob/master/LICENSE)
3
+ [![License](https://img.shields.io/github/license/voxpupuli/json-schema.svg)](https://github.com/voxpupuli/json-schema/blob/master/LICENSE.md)
4
4
  [![Test](https://github.com/voxpupuli/json-schema/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/json-schema/actions/workflows/test.yml)
5
5
  [![Release](https://github.com/voxpupuli/json-schema/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/json-schema/actions/workflows/release.yml)
6
6
  [![RubyGem Version](https://img.shields.io/gem/v/json-schema.svg)](https://rubygems.org/gems/json-schema)
@@ -12,7 +12,7 @@ module JSON
12
12
  if schema
13
13
  schema.validate(data, fragments, processor, options)
14
14
  elsif uri
15
- message = "The extended schema '#{uri.to_s}' cannot be found"
15
+ message = "The extended schema '#{uri}' cannot be found"
16
16
  validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
17
17
  else
18
18
  message = "The property '#{build_fragment(fragments)}' was not a valid schema"
@@ -10,7 +10,7 @@ module JSON
10
10
  regexp = Regexp.new(property)
11
11
 
12
12
  # Check each key in the data hash to see if it matches the regex
13
- data.each do |key, value|
13
+ data.each do |key, _value|
14
14
  next unless regexp.match(key)
15
15
 
16
16
  schema = JSON::Schema.new(property_schema, current_schema.uri, validator)
@@ -36,12 +36,12 @@ module JSON
36
36
  # When noAdditionalProperties is true, ensure no undefined properties exist in the data
37
37
  return unless options[:noAdditionalProperties] == true && !schema.key?('additionalProperties')
38
38
 
39
- diff = data.select do |k, v|
39
+ diff = data.select do |k, _v|
40
40
  k = k.to_s
41
41
 
42
42
  if schema.has_key?('patternProperties')
43
43
  match = false
44
- schema['patternProperties'].each do |property, property_schema|
44
+ schema['patternProperties'].each do |property, _property_schema|
45
45
  regexp = Regexp.new(property)
46
46
  if regexp.match(k)
47
47
  match = true
@@ -11,7 +11,7 @@ module JSON
11
11
  if schema
12
12
  schema.validate(data, fragments, processor, options)
13
13
  elsif uri
14
- message = "The referenced schema '#{uri.to_s}' cannot be found"
14
+ message = "The referenced schema '#{uri}' cannot be found"
15
15
  validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
16
16
  else
17
17
  message = "The property '#{build_fragment(fragments)}' was not a valid schema"
@@ -44,7 +44,7 @@ module JSON
44
44
  end
45
45
  fragment_path = fragment_path + "/#{fragment}"
46
46
  if target_schema.nil?
47
- raise SchemaError, "The fragment '#{fragment_path}' does not exist on schema #{ref_schema.uri.to_s}"
47
+ raise SchemaError, "The fragment '#{fragment_path}' does not exist on schema #{ref_schema.uri}"
48
48
  end
49
49
  end
50
50
  end
@@ -9,7 +9,7 @@ module JSON
9
9
  schema = current_schema.schema
10
10
  defined_properties = schema['properties']
11
11
 
12
- schema['required'].each do |property, property_schema|
12
+ schema['required'].each do |property, _property_schema|
13
13
  next if data.has_key?(property.to_s)
14
14
 
15
15
  prop_defaults = options[:insert_defaults] &&
@@ -20,7 +20,7 @@ module JSON
20
20
  messages = ["#{message}. The schema specific errors were:\n"]
21
21
  @sub_errors.each do |subschema, errors|
22
22
  messages.push "- #{subschema}:"
23
- messages.concat Array(errors).map { |e| "#{INDENT}- #{e.to_string(subschema_level + 1)}" }
23
+ messages.concat(Array(errors).map { |e| "#{INDENT}- #{e.to_string(subschema_level + 1)}" })
24
24
  end
25
25
  messages.map { |m| (INDENT * subschema_level) + m }.join("\n")
26
26
  end
@@ -20,7 +20,7 @@ module JSON
20
20
  end
21
21
 
22
22
  def validate(current_schema, data, fragments, processor, options = {})
23
- current_schema.schema.each do |attr_name, attribute|
23
+ current_schema.schema.each do |attr_name, _attribute|
24
24
  if @attributes.has_key?(attr_name.to_s)
25
25
  @attributes[attr_name.to_s].validate(current_schema, data, fragments, processor, self, options)
26
26
  end
@@ -35,7 +35,7 @@ module JSON
35
35
  def self.stringify(schema)
36
36
  case schema
37
37
  when Hash then
38
- schema.map { |key, value| [key.to_s, stringify(schema[key])] }.to_h
38
+ schema.map { |key, _value| [key.to_s, stringify(schema[key])] }.to_h
39
39
  when Array then
40
40
  schema.map do |schema_item|
41
41
  stringify(schema_item)
@@ -153,7 +153,7 @@ module JSON
153
153
  if t.nil? then
154
154
  # UUID epoch is 1582/Oct/15
155
155
  tt = Time.now
156
- t = tt.to_i * 10000000 + tt.tv_usec * 10 + 0x01B21DD213814000
156
+ t = (tt.to_i * 10000000) + (tt.tv_usec * 10) + 0x01B21DD213814000
157
157
  end
158
158
  c = c.succ # important; increment here
159
159
  write_state fp, c, m
@@ -220,7 +220,7 @@ module JSON
220
220
  def to_int
221
221
  tmp = raw_bytes.unpack 'C*'
222
222
  tmp.inject do |r, i|
223
- r * 256 | i
223
+ (r * 256) | i
224
224
  end
225
225
  end
226
226
  alias to_i to_int
@@ -180,7 +180,7 @@ module JSON
180
180
  %w[definitions properties patternProperties].each do |key|
181
181
  next unless value = schema[key]
182
182
 
183
- value.each do |k, inner_schema|
183
+ value.each do |_k, inner_schema|
184
184
  handle_schema(parent_schema, inner_schema)
185
185
  end
186
186
  end
@@ -377,7 +377,7 @@ module JSON
377
377
  @@default_validator = v
378
378
  end
379
379
 
380
- def register_format_validator(format, validation_proc, versions = (@@validators.flat_map { |k, v| v.names.first } + [nil]))
380
+ def register_format_validator(format, validation_proc, versions = (@@validators.flat_map { |_k, v| v.names.first } + [nil]))
381
381
  custom_format_validator = JSON::Schema::CustomFormat.new(validation_proc)
382
382
  versions.each do |version|
383
383
  validator = validator_for_name(version)
@@ -385,14 +385,14 @@ module JSON
385
385
  end
386
386
  end
387
387
 
388
- def deregister_format_validator(format, versions = (@@validators.flat_map { |k, v| v.names.first } + [nil]))
388
+ def deregister_format_validator(format, versions = (@@validators.flat_map { |_k, v| v.names.first } + [nil]))
389
389
  versions.each do |version|
390
390
  validator = validator_for_name(version)
391
391
  validator.formats[format.to_s] = validator.default_formats[format.to_s]
392
392
  end
393
393
  end
394
394
 
395
- def restore_default_formats(versions = (@@validators.flat_map { |k, v| v.names.first } + [nil]))
395
+ def restore_default_formats(versions = (@@validators.flat_map { |_k, v| v.names.first } + [nil]))
396
396
  versions.each do |version|
397
397
  validator = validator_for_name(version)
398
398
  validator.formats = validator.default_formats.clone
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: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenny Hoxworth
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-08-19 00:00:00.000000000 Z
12
+ date: 2024-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 2.8.0
48
+ version: 3.0.0
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 2.8.0
55
+ version: 3.0.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: webmock
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -179,6 +179,7 @@ metadata:
179
179
  source_code_uri: https://github.com/voxpupuli/json-schema/
180
180
  changelog_uri: https://github.com/voxpupuli/json-schema//blob/master/CHANGELOG.md
181
181
  bug_tracker_uri: https://github.com/voxpupuli/json-schema//issues
182
+ funding_uri: https://github.com/sponsors/voxpupuli
182
183
  post_install_message:
183
184
  rdoc_options: []
184
185
  require_paths:
@@ -194,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
195
  - !ruby/object:Gem::Version
195
196
  version: '0'
196
197
  requirements: []
197
- rubygems_version: 3.5.11
198
+ rubygems_version: 3.5.22
198
199
  signing_key:
199
200
  specification_version: 4
200
201
  summary: Ruby JSON Schema Validator