apia 3.0.2 → 3.0.3

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: 149ff24b39258aecaa9aaf738ff5d65c0d4ef24ccbc74844ae4ae12df5fe3e07
4
- data.tar.gz: 5c6a4ea4c17f482e6b2614a44aab4e3bf7e9eccae7caacb1acdabe000f7f6838
3
+ metadata.gz: 33cb0099fcbfe56a47b0c3f6253252a7fbe64963627695d8580936f72731ee37
4
+ data.tar.gz: 9744e82b89172cad5f5eac2870484f43dfe0cf23e793e2db6265b7dcbdd20f12
5
5
  SHA512:
6
- metadata.gz: 2b85dd5fea1f2f566e687686883180d73c53f0623598a3552a8f2566ebe6ff0f8987c3446334b2947b83e355466886ffd092b25e132275a1b783c1b2488f0e1e
7
- data.tar.gz: 7ee2812dc10ac8928bcb9674a18fee6ab6fae117becc9f43a864dc4d35ad7db6bbc95c3ea61d80bcb029e8feb3c463260c012c036d255df8b36205c1ee628831
6
+ metadata.gz: 195b2874b6deeeb9d52f8fd568cf553da7fd09f43a10e04a4302736eae62ea3ecd4272077e8b7d446cfb46a74d9023ba6af69c6d6d5796ecf3036fcb95bde9d2
7
+ data.tar.gz: 8f37aca1ff128cbe3d3fe6b0341a64b68df34ba273f6eb7503c8c3b8ec6e672fb14efe24f589e40f81c1d3fb325e6f0649dc5ccdb0a55925bcf68f9818d995c7
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.2
1
+ 3.0.3
@@ -5,6 +5,7 @@ require 'apia/definitions/argument_set'
5
5
  require 'apia/errors/invalid_argument_error'
6
6
  require 'apia/errors/missing_argument_error'
7
7
  require 'apia/helpers'
8
+ require 'apia/deep_merge'
8
9
 
9
10
  module Apia
10
11
  class ArgumentSet
@@ -46,7 +47,11 @@ module Apia
46
47
  # @param request [Apia::Request]
47
48
  # @return [Apia::ArgumentSet]
48
49
  def create_from_request(request)
49
- new(request.json_body || request.params || {}, request: request)
50
+ json_body = request.json_body || {}
51
+ params = request.params || {}
52
+ merged_params = DeepMerge.merge(params, json_body)
53
+
54
+ new(merged_params, request: request)
50
55
  end
51
56
 
52
57
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apia
4
+ module DeepMerge
5
+
6
+ class << self
7
+
8
+ def merge(hash_a, hash_b, &block)
9
+ hash_a.merge!(hash_b) do |key, this_val, other_val|
10
+ if this_val.is_a?(Hash) && other_val.is_a?(Hash)
11
+ merge(this_val, other_val, &block)
12
+ elsif block_given?
13
+ block.call(key, this_val, other_val)
14
+ else
15
+ other_val
16
+ end
17
+ end
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+ end
data/lib/apia/request.rb CHANGED
@@ -39,6 +39,12 @@ module Apia
39
39
  has_header?('rack.input')
40
40
  end
41
41
 
42
+ def params
43
+ return {} unless body?
44
+
45
+ super
46
+ end
47
+
42
48
  private
43
49
 
44
50
  def parse_json_from_string(body)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apia
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cooke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-18 00:00:00.000000000 Z
11
+ date: 2021-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -52,6 +52,7 @@ files:
52
52
  - lib/apia/authenticator.rb
53
53
  - lib/apia/callable_with_environment.rb
54
54
  - lib/apia/controller.rb
55
+ - lib/apia/deep_merge.rb
55
56
  - lib/apia/defineable.rb
56
57
  - lib/apia/definition.rb
57
58
  - lib/apia/definitions/api.rb