http-client-generator 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: edc63e0a164b0694ebe93647137b6b825061c57064cf851f4675c5e2955e6fd6
4
- data.tar.gz: 68ee612dc6a37f278351736ab53fe8d2a85598314c570b65bb4e9f7daffc9463
3
+ metadata.gz: 547094492a3531c3719f9d0aa0909b98d6f41f429da5670ec764cd73a507581d
4
+ data.tar.gz: 64cb0d19b54b4f8d6b0acb4fc79d780810dc6abf42f94faa5541af5f586525b8
5
5
  SHA512:
6
- metadata.gz: 6b15241122952c07b5560047c505e5bffb0a2f6c2ff80c5626de3a152636766fd9a61e72ff01c9734b06a235aa7aaa33796af544c621e801c5088377f22f50f6
7
- data.tar.gz: a5663a4c5f8f1c8daeb0e83f3cbefff6f5d6499f5f0ff5011c8324cd9a27780ed0bffce2b9902f37386ad1e91890f532f6e825d536d0e897fbaa2838a7bd4dcc
6
+ metadata.gz: 9d0f5a805bc01653ad6d932d2e3df5988fdc7d2cad413ff9e4e35c0caf0c822fa9ffe94d5b7df15e4fe2d8d897a1d2304697160647e1905e459a36321bce2d3a
7
+ data.tar.gz: 5105a5eb18be5e0cd16802ad99ded20b34951e76ac6b1d8dd71cfc8b5b9cfe40685a56e187d1e761899d7f728ddf17593561735bee5b7c9e09f87e973008536b
@@ -5,8 +5,9 @@ module HttpClientGenerator
5
5
  class ValidateRequest
6
6
  Plugs.register :validate_request, self
7
7
 
8
- def initialize(schema_helper:)
8
+ def initialize(schema_helper:, show_body_in_error: false)
9
9
  @schema_helper = schema_helper
10
+ @show_body_in_error = show_body_in_error
10
11
  end
11
12
 
12
13
  def call(req)
@@ -14,8 +15,19 @@ module HttpClientGenerator
14
15
 
15
16
  return req unless @schema_helper.respond_to?(schema_name)
16
17
 
17
- req.response_body = @schema_helper.public_send(schema_name, req.body)
18
- .value_or { |e| req.raise_message("Unexpected #{e.inspect} in #{req.body}") }
18
+ req.response_body =
19
+ @schema_helper
20
+ .public_send(schema_name, req.body)
21
+ .value_or do |e|
22
+ message =
23
+ if @show_body_in_error
24
+ "Unexpected #{e.inspect} in #{req.body}"
25
+ else
26
+ "Unexpected #{e.inspect}"
27
+ end
28
+
29
+ req.raise_message(message)
30
+ end
19
31
 
20
32
  req
21
33
  end
@@ -5,8 +5,9 @@ module HttpClientGenerator
5
5
  class ValidateResponse
6
6
  Plugs.register :validate_response, self
7
7
 
8
- def initialize(schema_helper:)
8
+ def initialize(schema_helper:, show_body_in_error: false)
9
9
  @schema_helper = schema_helper
10
+ @show_body_in_error = show_body_in_error
10
11
  end
11
12
 
12
13
  def call(req)
@@ -14,8 +15,19 @@ module HttpClientGenerator
14
15
 
15
16
  return req unless @schema_helper.respond_to?(schema_name)
16
17
 
17
- req.response_body = @schema_helper.public_send(schema_name, req.response_body)
18
- .value_or { |e| req.raise_message("Unexpected #{e.inspect} in #{req.response_body}") }
18
+ req.response_body =
19
+ @schema_helper
20
+ .public_send(schema_name, req.response_body)
21
+ .value_or do |e|
22
+ message =
23
+ if @show_body_in_error
24
+ "Unexpected #{e.inspect} in #{req.response_body}"
25
+ else
26
+ "Unexpected #{e.inspect}"
27
+ end
28
+
29
+ req.raise_message(message)
30
+ end
19
31
 
20
32
  req
21
33
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HttpClientGenerator
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-client-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Egorov