json_schemer 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 460e70448c0b37c65fd4e51f046036336b17121cc716c197fe80f2e2517f45e7
4
- data.tar.gz: f06d11eab9bb88c45a018c8913d6a5d2e33162064c9f995e5772beb811e68ed6
3
+ metadata.gz: 57b910832ad52857f782a9e0c9d17247b3d298493e2876d4d87dcc7bd72c623e
4
+ data.tar.gz: 4f36b7e698c0de3b9cac3d5fc54572dfd2288f28e0e29c7475f162cf5e878c95
5
5
  SHA512:
6
- metadata.gz: 83549b328ba3067ed206a8bdea448e34ba274c7c5a7857d38793d74f0691339f845b0e39fdbb0ff8c3869dfbaf0dcd13380c458c80397b100a848f96443bf691
7
- data.tar.gz: 106314824f1805e7d2306c10c696d4503b54b4d9203321e37816242c30598c3870ec40ade53dc08692ec3b2a35f18360c96211f0b8af44fd4414931da4e5b1e5
6
+ metadata.gz: 6cb5d43a92de555b7fb72febcd305990b94ed7764bfb300a158ec3ee864e4d7c9944afa4ff4726ce30e57af0325a8bb9e295e281b4b981cc459f44ddd3e507da
7
+ data.tar.gz: f41eab50d37542486c230fcbe14a57c7dbb6564acac9815a3ff4b9977a7683a9703162d59650e34c3dc640693fa919c6b607403e575b233c77468fcc39f0703b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- json_schemer (1.0.1)
4
+ json_schemer (1.0.2)
5
5
  hana (~> 1.3)
6
6
  regexp_parser (~> 2.0)
7
7
  simpleidn (~> 0.2)
@@ -66,7 +66,7 @@ module JSONSchemer
66
66
  def valid_date_time?(data)
67
67
  return false if HOUR_24_REGEX.match?(data)
68
68
  datetime = DateTime.rfc3339(data)
69
- return false if LEAP_SECOND_REGEX.match?(data) && datetime.to_time.utc.strftime('%H:%M') != '23:59'
69
+ return false if LEAP_SECOND_REGEX.match?(data) && datetime.new_offset.strftime('%H:%M') != '23:59'
70
70
  DATE_TIME_OFFSET_REGEX.match?(data)
71
71
  rescue ArgumentError
72
72
  false
@@ -330,10 +330,10 @@ module JSONSchemer
330
330
  child(resolve_ref(ref_uri), base_uri: ref_uri)
331
331
  end
332
332
 
333
- ref_schema, ref_schema_pointer = ref_object.ids[ref_uri] || [ref_object.root, '']
333
+ ref_schema, ref_schema_pointer, ref_parent_base_uri = ref_object.ids[ref_uri] || [ref_object.root, '', ref_uri]
334
334
 
335
335
  ref_uri_pointer_parts = Hana::Pointer.parse(URI.decode_www_form_component(ref_uri_pointer))
336
- schema, base_uri = ref_uri_pointer_parts.reduce([ref_schema, ref_uri]) do |(obj, uri), token|
336
+ schema, base_uri = ref_uri_pointer_parts.reduce([ref_schema, ref_parent_base_uri]) do |(obj, uri), token|
337
337
  if obj.is_a?(Array)
338
338
  [obj.fetch(token.to_i), uri]
339
339
  else
@@ -646,16 +646,18 @@ module JSONSchemer
646
646
  if schema.is_a?(Array)
647
647
  schema.each_with_index { |subschema, index| resolve_ids(subschema, ids, base_uri, "#{pointer}/#{index}") }
648
648
  elsif schema.is_a?(Hash)
649
- uri = join_uri(base_uri, schema[id_keyword])
649
+ if schema.key?(id_keyword)
650
+ parent_base_uri = base_uri
651
+ base_uri = join_uri(base_uri, schema[id_keyword])
652
+ ids[base_uri] ||= [schema, pointer, parent_base_uri]
653
+ end
650
654
  schema.each do |key, value|
651
655
  case key
652
- when id_keyword
653
- ids[uri] ||= [schema, pointer]
654
656
  when 'items', 'allOf', 'anyOf', 'oneOf', 'additionalItems', 'contains', 'additionalProperties', 'propertyNames', 'if', 'then', 'else', 'not'
655
- resolve_ids(value, ids, uri, "#{pointer}/#{key}")
657
+ resolve_ids(value, ids, base_uri, "#{pointer}/#{key}")
656
658
  when 'properties', 'patternProperties', 'definitions', 'dependencies'
657
659
  value.each do |subkey, subvalue|
658
- resolve_ids(subvalue, ids, uri, "#{pointer}/#{key}/#{subkey}")
660
+ resolve_ids(subvalue, ids, base_uri, "#{pointer}/#{key}/#{subkey}")
659
661
  end
660
662
  end
661
663
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module JSONSchemer
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_schemer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Harsha
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-27 00:00:00.000000000 Z
11
+ date: 2023-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler