Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent throwing another exception if the request fails eg connection reset #715

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ module {{moduleName}}
tempfile.write(chunk)
end
request.on_complete do |response|
tempfile.close
tempfile.close if tempfile
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note shouldn't there be a way to turn this off?

"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
Expand Down
6 changes: 3 additions & 3 deletions samples/client/petstore/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ client = Petstore::Client.new # Client | client model

begin
#To test special tags
result = api_instance.test_special_tags(client)
result = api_instance.123_test_special_tags(client)
p result
rescue Petstore::ApiError => e
puts "Exception when calling AnotherFakeApi->test_special_tags: #{e}"
puts "Exception when calling AnotherFakeApi->123_test_special_tags: #{e}"
end

```
Expand All @@ -73,7 +73,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*Petstore::AnotherFakeApi* | [**test_special_tags**](docs/AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
*Petstore::AnotherFakeApi* | [**123_test_special_tags**](docs/AnotherFakeApi.md#123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
*Petstore::FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean |
*Petstore::FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite |
*Petstore::FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number |
Expand Down
12 changes: 6 additions & 6 deletions samples/client/petstore/ruby/docs/AnotherFakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*

Method | HTTP request | Description
------------- | ------------- | -------------
[**test_special_tags**](AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
[**123_test_special_tags**](AnotherFakeApi.md#123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags


# **test_special_tags**
> Client test_special_tags(client)
# **123_test_special_tags**
> Client 123_test_special_tags(client)

To test special tags

To test special tags
To test special tags and operation ID starting with number

### Example
```ruby
Expand All @@ -24,10 +24,10 @@ client = Petstore::Client.new # Client | client model

begin
#To test special tags
result = api_instance.test_special_tags(client)
result = api_instance.123_test_special_tags(client)
p result
rescue Petstore::ApiError => e
puts "Exception when calling AnotherFakeApi->test_special_tags: #{e}"
puts "Exception when calling AnotherFakeApi->123_test_special_tags: #{e}"
end
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@ def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# To test special tags
# To test special tags
# To test special tags and operation ID starting with number
# @param client client model
# @param [Hash] opts the optional parameters
# @return [Client]
def test_special_tags(client, opts = {})
data, _status_code, _headers = test_special_tags_with_http_info(client, opts)
def 123_test_special_tags(client, opts = {})
data, _status_code, _headers = 123_test_special_tags_with_http_info(client, opts)
data
end

# To test special tags
# To test special tags
# To test special tags and operation ID starting with number
# @param client client model
# @param [Hash] opts the optional parameters
# @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers
def test_special_tags_with_http_info(client, opts = {})
def 123_test_special_tags_with_http_info(client, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: AnotherFakeApi.test_special_tags ...'
@api_client.config.logger.debug 'Calling API: AnotherFakeApi.123_test_special_tags ...'
end
# verify the required parameter 'client' is set
if @api_client.config.client_side_validation && client.nil?
fail ArgumentError, "Missing the required parameter 'client' when calling AnotherFakeApi.test_special_tags"
fail ArgumentError, "Missing the required parameter 'client' when calling AnotherFakeApi.123_test_special_tags"
end
# resource path
local_var_path = '/another-fake/dummy'
Expand Down Expand Up @@ -69,7 +69,7 @@ def test_special_tags_with_http_info(client, opts = {})
:auth_names => auth_names,
:return_type => 'Client')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: AnotherFakeApi#test_special_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
@api_client.config.logger.debug "API called: AnotherFakeApi#123_test_special_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/ruby/lib/petstore/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def download_file(request)
tempfile.write(chunk)
end
request.on_complete do |response|
tempfile.close
tempfile.close if tempfile
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
Expand Down