openapi_parameters 0.3.1 → 0.3.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: 25ce53f3254aebc92f56f59faf54a0b82a26a9908956c5f9ef1e6696f42d5ef9
4
- data.tar.gz: 134af6813487d225ded3b84040f7039276f64906d2d4be635ac2681689035553
3
+ metadata.gz: ce377792c0096d9aba455f83d129162c636f6cab951e43221de7dfbfb9e67227
4
+ data.tar.gz: e8f320696d3af924bd25496c6f98e19222af638365bfd39d5199b0da27104002
5
5
  SHA512:
6
- metadata.gz: b5229198046f5e0455ed437110c170024131b5046aaaea598471080804a3e56774997640f323b463567e197308668874633c8186cbf518871a013cfbe4bd1593
7
- data.tar.gz: 517df02187fe286fb67d21f9bd807fdc07bcdea04e62df0fce16a32bb994215d6706b47c97f6ec32e59c439edccee23e13a993b3b59c390b623f4f53f28850a6
6
+ metadata.gz: 67bf514be29731af8936dbab3ec1dfcb61b1091332487f4602c56bab7a708dd9637925b8e58c819d9d39d75e4bf861800dfaf407608837f846f2ed3b09f6cf2d
7
+ data.tar.gz: cf4f96c5a4e0f4c0b025eaa116dd3e38d040f6e1ef2be0cde8b3a2b1f871d5b027454ed1d57ca69ccb3310ae84162488c4111797985cf9ec3a0b321c2f30d717
data/.rubocop.yml CHANGED
@@ -12,5 +12,8 @@ AllCops:
12
12
  RSpec/ExampleLength:
13
13
  Enabled: false
14
14
 
15
+ RSpec/NestedGroups:
16
+ Max: 4
17
+
15
18
  Metrics/MethodLength:
16
19
  Max: 20
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.2] - 2023-11-14
4
+
5
+ - Assume that schemas with `properties` or `style: deepObject` describe Objects and therefore convert it's values.
6
+
3
7
  ## [0.3.1] - 2023-11-09
8
+
4
9
  - Make it work with Zeitwerk's `eager_load`
5
10
 
6
11
  ## [0.3.0] - 2023-10-27
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openapi_parameters (0.3.1)
4
+ openapi_parameters (0.3.2)
5
5
  rack (>= 2.2)
6
6
  zeitwerk (~> 2.6)
7
7
 
@@ -19,12 +19,12 @@ GEM
19
19
  parser (3.2.2.4)
20
20
  ast (~> 2.4.1)
21
21
  racc
22
- racc (1.7.1)
22
+ racc (1.7.3)
23
23
  rack (3.0.8)
24
24
  rack-test (2.1.0)
25
25
  rack (>= 1.3)
26
26
  rainbow (3.1.1)
27
- rake (13.0.6)
27
+ rake (13.1.0)
28
28
  regexp_parser (2.8.2)
29
29
  rexml (3.2.6)
30
30
  rspec (3.12.0)
@@ -36,7 +36,17 @@ module OpenapiParameters
36
36
  when 'array'
37
37
  convert_array(value, schema)
38
38
  else
39
- value
39
+ if schema['properties']
40
+ convert_object(value, schema)
41
+ else
42
+ value
43
+ end
44
+ end
45
+ end
46
+
47
+ def convert_object(object, schema)
48
+ object.each_with_object({}) do |(key, value), hsh|
49
+ hsh[key] = convert(value, schema['properties']&.fetch(key, nil))
40
50
  end
41
51
  end
42
52
 
@@ -46,12 +56,6 @@ module OpenapiParameters
46
56
  schema && schema['type']
47
57
  end
48
58
 
49
- def convert_object(object, schema)
50
- object.each_with_object({}) do |(key, value), hsh|
51
- hsh[key] = convert(value, schema['properties']&.fetch(key))
52
- end
53
- end
54
-
55
59
  def convert_array(array, schema)
56
60
  return array unless array.is_a?(Array)
57
61
 
@@ -47,7 +47,7 @@ module OpenapiParameters
47
47
  end
48
48
 
49
49
  def object?
50
- type == 'object'
50
+ type == 'object' || style == 'deepObject' || schema&.key?('properties')
51
51
  end
52
52
 
53
53
  def style
@@ -16,7 +16,7 @@ module OpenapiParameters
16
16
  parsed_query = Rack::Utils.parse_query(query_string)
17
17
  parameters.each_with_object({}) do |parameter, result|
18
18
  parameter = Parameter.new(parameter)
19
- if parameter.style == 'deepObject' && parameter.object?
19
+ if parameter.style == 'deepObject'
20
20
  parsed_nested_query = Rack::Utils.parse_nested_query(query_string)
21
21
  next unless parsed_nested_query.key?(parameter.name)
22
22
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenapiParameters
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_parameters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Haller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-09 00:00:00.000000000 Z
11
+ date: 2023-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack