Skip to content

Commit

Permalink
fix(response-handler): void response handling with complete http resp…
Browse files Browse the repository at this point in the history
…onse setting

This commit ensures that the ResponseHandler returns an ApiResponse object even when the response is void.  Consequently, this addresses the issue where the endpoint receives `nil` instead of an ApiResponse object.
  • Loading branch information
sufyankhanrao committed Aug 27, 2024
1 parent a3e5df4 commit 7bddd43
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apimatic_core.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'apimatic_core'
s.version = '0.3.9'
s.version = '0.3.10'
s.summary = 'A library that contains apimatic-apimatic-core logic and utilities for consuming REST APIs using Python SDKs generated '\
'by APIMatic.'
s.description = 'The APIMatic Core libraries provide a stable runtime that powers all the functionality of SDKs.'\
Expand Down
2 changes: 1 addition & 1 deletion lib/apimatic-core/response_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def handle(response, global_errors, should_symbolize_hash = false)
# validating response if configured
validate(response, global_errors)

return if @is_response_void
return if @is_response_void && !@is_api_response

# applying deserializer if configured
deserialized_value = apply_deserializer(response, should_symbolize_hash)
Expand Down
10 changes: 10 additions & 0 deletions test/test-apimatic-core/response_handler_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,16 @@ def test_void_response
assert_nil(actual_response)
end


def test_void_response_with_api_response
response_mock = MockHelper.create_response status_code: 200
actual_response = @response_handler.is_response_void(true).is_api_response(true)
.handle(response_mock, MockHelper.get_global_errors)

refute_nil(actual_response)
assert_equal(200, actual_response.status_code)
end

def test_no_deserializer_configured_case
response_body_mock = 'This is simple response.'
response_mock = MockHelper.create_response status_code: 200,
Expand Down

0 comments on commit 7bddd43

Please sign in to comment.