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 +4 -4
- data/VERSION +1 -1
- data/lib/apia/argument_set.rb +6 -1
- data/lib/apia/deep_merge.rb +23 -0
- data/lib/apia/request.rb +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33cb0099fcbfe56a47b0c3f6253252a7fbe64963627695d8580936f72731ee37
|
4
|
+
data.tar.gz: 9744e82b89172cad5f5eac2870484f43dfe0cf23e793e2db6265b7dcbdd20f12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 195b2874b6deeeb9d52f8fd568cf553da7fd09f43a10e04a4302736eae62ea3ecd4272077e8b7d446cfb46a74d9023ba6af69c6d6d5796ecf3036fcb95bde9d2
|
7
|
+
data.tar.gz: 8f37aca1ff128cbe3d3fe6b0341a64b68df34ba273f6eb7503c8c3b8ec6e672fb14efe24f589e40f81c1d3fb325e6f0649dc5ccdb0a55925bcf68f9818d995c7
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.0.3
|
data/lib/apia/argument_set.rb
CHANGED
@@ -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
|
-
|
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
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.
|
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-
|
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
|