openapi_parameters 0.3.0 → 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: aa586602013f736682059c6e4615dbd4eb7e57daaa4633e6fb35982261a39e11
4
- data.tar.gz: 772345d845efdf6d191c362176deac63036cf064fbd4145c8b375f9bf500faaf
3
+ metadata.gz: ce377792c0096d9aba455f83d129162c636f6cab951e43221de7dfbfb9e67227
4
+ data.tar.gz: e8f320696d3af924bd25496c6f98e19222af638365bfd39d5199b0da27104002
5
5
  SHA512:
6
- metadata.gz: 8d21a6c44fc2a1d6d72a3b4cd2bab4804ee4ddfd62d5cf73d3407bf913583b0733b61e9b567da45dca13f9bf2007d58ac6b45fb71299ffa509385aaa1f05b18a
7
- data.tar.gz: d7cc40c0551910ba432955e7008762950d8c65df0b06e45d094dca0f8b601c6bacc68e6ef8d223471d9f59c112f7a872fd2a5903a7f78de2d70f0580ccfc9115
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,5 +1,13 @@
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
+
7
+ ## [0.3.1] - 2023-11-09
8
+
9
+ - Make it work with Zeitwerk's `eager_load`
10
+
3
11
  ## [0.3.0] - 2023-10-27
4
12
 
5
13
  - Query parameters: Don't attempt to convert arras within deepObject objects. Behaviour is not defined in OpenApi 3.1.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openapi_parameters (0.3.0)
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
 
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenapiParameters
4
+ class Error < StandardError
5
+ end
6
+ end
@@ -1,9 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenapiParameters
4
- class Error < StandardError
5
- end
6
-
7
4
  class NotSupportedError < Error
8
5
  end
9
6
  end
@@ -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.0'
4
+ VERSION = '0.3.2'
5
5
  end
@@ -1,11 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'zeitwerk'
4
- loader = Zeitwerk::Loader.for_gem
5
- loader.setup
6
4
 
7
5
  # OpenapiParameters is a gem that parses OpenAPI parameters from Rack
8
6
  module OpenapiParameters
7
+ LOADER = Zeitwerk::Loader.for_gem
8
+ LOADER.setup
9
9
  end
10
-
11
- require_relative 'openapi_parameters/errors'
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.0
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-10-27 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
@@ -58,9 +58,10 @@ files:
58
58
  - lib/openapi_parameters.rb
59
59
  - lib/openapi_parameters/converter.rb
60
60
  - lib/openapi_parameters/cookie.rb
61
- - lib/openapi_parameters/errors.rb
61
+ - lib/openapi_parameters/error.rb
62
62
  - lib/openapi_parameters/header.rb
63
63
  - lib/openapi_parameters/headers_hash.rb
64
+ - lib/openapi_parameters/not_supported_error.rb
64
65
  - lib/openapi_parameters/parameter.rb
65
66
  - lib/openapi_parameters/path.rb
66
67
  - lib/openapi_parameters/query.rb