json_schemer 2.1.0 → 2.1.1

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: bd2081bcd9677b1615f3076f9c83171bba0f4a9c7030b94f175ea0b350b75b7c
4
- data.tar.gz: 920692383076ade224cb1b1f02f1579a824792c07333ebdee467596a0c3e3b6a
3
+ metadata.gz: 1981782f2342c7123beb0374680037bc11f3be72a8e4be0a213cfb7691643415
4
+ data.tar.gz: e8b6c605ba1ce2a2751ac90167f53c27fad975140ab9a0e8328c2b04ce8fe732
5
5
  SHA512:
6
- metadata.gz: 84f674bd5560c44cbc752a18365cfbff341bb4e94a7cae43674d5591bb2229e0bd5d096346bca9e8ef54313c500496195ebabcb3d3100a39346e23be4d984f20
7
- data.tar.gz: 77a8391db7a554ec8ff93b155c77f0945984a194a3f64178d3f184fdbfc21806736f18788295579812ddc138c6b5a1dde977a16e8aa3b8c7edf7545c15eae3fa
6
+ metadata.gz: 4d4c6e6c3660560a602b5610559efe37b5839f1142af6486e350bd207cad49e37a00f397d555878957b14951da95745092240bd14417e2ffd02826f053099952
7
+ data.tar.gz: 8dc561414463ceeacf7bbd0be95be9c441a50919cdb839ff8366fa0268d96d91e4947985bd7bab406f3c163e913bf7ca923a38e22d777d2549af3329f91c14f2
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Changelog
2
2
 
3
- ## [2.1.0] - XXXX-XX-XX
3
+ ## [2.1.1] - 2023-11-28
4
+
5
+ ### Bug Fixes
6
+
7
+ - Fix refs to/through keyword objects: https://github.com/davishmcclurg/json_schemer/pull/160
8
+ - Temporary fix for incorrect `uri-reference` format in OpenAPI 3.x: https://github.com/davishmcclurg/json_schemer/pull/161
9
+
10
+ [2.1.1]: https://github.com/davishmcclurg/json_schemer/releases/tag/v2.1.1
11
+
12
+ ## [2.1.0] - 2023-11-17
4
13
 
5
14
  ### Bug Fixes
6
15
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- json_schemer (2.1.0)
4
+ json_schemer (2.1.1)
5
5
  hana (~> 1.3)
6
6
  regexp_parser (~> 2.0)
7
7
  simpleidn (~> 0.2)
@@ -30,7 +30,7 @@ GEM
30
30
  unf (0.1.4)
31
31
  unf_ext
32
32
  unf (0.1.4-java)
33
- unf_ext (0.0.9)
33
+ unf_ext (0.0.9.1)
34
34
 
35
35
  PLATFORMS
36
36
  java
@@ -136,7 +136,7 @@ module JSONSchemer
136
136
  end
137
137
  end
138
138
 
139
- def fetch_unknown!(token)
139
+ def fetch(token)
140
140
  if value.is_a?(Hash)
141
141
  parsed[token] ||= JSONSchemer::Schema::UNKNOWN_KEYWORD_CLASS.new(value.fetch(token), self, token, schema)
142
142
  elsif value.is_a?(Array)
@@ -146,8 +146,8 @@ module JSONSchemer
146
146
  end
147
147
  end
148
148
 
149
- def unknown_schema!
150
- @unknown_schema ||= subschema(value)
149
+ def parsed_schema
150
+ @parsed_schema ||= subschema(value)
151
151
  end
152
152
 
153
153
  def validate(instance, instance_location, keyword_location, _context)
@@ -30,6 +30,14 @@ module JSONSchemer
30
30
  keyword
31
31
  end
32
32
 
33
+ def fetch(key)
34
+ parsed.fetch(parsed.is_a?(Array) ? key.to_i : key)
35
+ end
36
+
37
+ def parsed_schema
38
+ parsed.is_a?(Schema) ? parsed : nil
39
+ end
40
+
33
41
  private
34
42
 
35
43
  def parse
@@ -1584,8 +1584,7 @@ module JSONSchemer
1584
1584
  'type' => 'string'
1585
1585
  },
1586
1586
  'operationRef' => {
1587
- 'type' => 'string',
1588
- 'format' => 'uri-reference'
1587
+ 'type' => 'string'
1589
1588
  },
1590
1589
  'parameters' => {
1591
1590
  'type' => 'object',
@@ -270,8 +270,7 @@ module JSONSchemer
270
270
  'type' => 'object',
271
271
  'properties' => {
272
272
  'url' => {
273
- 'type' => 'string',
274
- 'format' => 'uri-reference'
273
+ 'type' => 'string'
275
274
  },
276
275
  'description' => {
277
276
  'type' => 'string'
@@ -1054,8 +1053,7 @@ module JSONSchemer
1054
1053
  'type' => 'object',
1055
1054
  'properties' => {
1056
1055
  'operationRef' => {
1057
- 'type' => 'string',
1058
- 'format' => 'uri-reference'
1056
+ 'type' => 'string'
1059
1057
  },
1060
1058
  'operationId' => {
1061
1059
  'type' => 'string'
@@ -203,18 +203,13 @@ module JSONSchemer
203
203
  end
204
204
 
205
205
  schema = Hana::Pointer.parse(pointer).reduce(schema) do |obj, token|
206
- if obj.is_a?(UNKNOWN_KEYWORD_CLASS)
207
- obj.fetch_unknown!(token)
208
- elsif obj.parsed.is_a?(Array)
209
- obj.parsed.fetch(token.to_i)
210
- else
211
- obj.parsed.fetch(token)
212
- end
206
+ obj.fetch(token)
213
207
  rescue IndexError
214
208
  raise InvalidRefPointer, pointer
215
209
  end
216
210
 
217
- schema = schema.unknown_schema! unless schema.is_a?(Schema)
211
+ schema = schema.parsed_schema if schema.is_a?(Keyword)
212
+ raise InvalidRefPointer, pointer unless schema.is_a?(Schema)
218
213
 
219
214
  schema
220
215
  end
@@ -299,6 +294,10 @@ module JSONSchemer
299
294
  '^'
300
295
  end
301
296
 
297
+ def fetch(key)
298
+ parsed.fetch(key)
299
+ end
300
+
302
301
  def fetch_format(format, *args, &block)
303
302
  if meta_schema == self
304
303
  formats.fetch(format, *args, &block)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module JSONSchemer
3
- VERSION = '2.1.0'
3
+ VERSION = '2.1.1'
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: 2.1.0
4
+ version: 2.1.1
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-11-17 00:00:00.000000000 Z
11
+ date: 2023-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler