forked from loafle/openapi-generator-original
Merge pull request #1761 from xhh/ruby-timeout
Ruby client: add "timeout" to configuration
This commit is contained in:
commit
858d44a27f
@ -71,6 +71,7 @@ module {{moduleName}}
|
|||||||
:method => http_method,
|
:method => http_method,
|
||||||
:headers => header_params,
|
:headers => header_params,
|
||||||
:params => query_params,
|
:params => query_params,
|
||||||
|
:timeout => @config.timeout,
|
||||||
:ssl_verifypeer => @config.verify_ssl,
|
:ssl_verifypeer => @config.verify_ssl,
|
||||||
:sslcert => @config.cert_file,
|
:sslcert => @config.cert_file,
|
||||||
:sslkey => @config.key_file,
|
:sslkey => @config.key_file,
|
||||||
|
@ -60,6 +60,10 @@ module {{moduleName}}
|
|||||||
# @return [String]
|
# @return [String]
|
||||||
attr_accessor :temp_folder_path
|
attr_accessor :temp_folder_path
|
||||||
|
|
||||||
|
# The time limit for HTTP request in seconds.
|
||||||
|
# Default to 0 (never times out).
|
||||||
|
attr_accessor :timeout
|
||||||
|
|
||||||
### TLS/SSL
|
### TLS/SSL
|
||||||
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
||||||
# Default to true.
|
# Default to true.
|
||||||
@ -93,6 +97,7 @@ module {{moduleName}}
|
|||||||
@base_path = '{{contextPath}}'
|
@base_path = '{{contextPath}}'
|
||||||
@api_key = {}
|
@api_key = {}
|
||||||
@api_key_prefix = {}
|
@api_key_prefix = {}
|
||||||
|
@timeout = 0
|
||||||
@verify_ssl = true
|
@verify_ssl = true
|
||||||
@cert_file = nil
|
@cert_file = nil
|
||||||
@key_file = nil
|
@key_file = nil
|
||||||
|
@ -71,6 +71,7 @@ module Petstore
|
|||||||
:method => http_method,
|
:method => http_method,
|
||||||
:headers => header_params,
|
:headers => header_params,
|
||||||
:params => query_params,
|
:params => query_params,
|
||||||
|
:timeout => @config.timeout,
|
||||||
:ssl_verifypeer => @config.verify_ssl,
|
:ssl_verifypeer => @config.verify_ssl,
|
||||||
:sslcert => @config.cert_file,
|
:sslcert => @config.cert_file,
|
||||||
:sslkey => @config.key_file,
|
:sslkey => @config.key_file,
|
||||||
|
@ -60,6 +60,10 @@ module Petstore
|
|||||||
# @return [String]
|
# @return [String]
|
||||||
attr_accessor :temp_folder_path
|
attr_accessor :temp_folder_path
|
||||||
|
|
||||||
|
# The time limit for HTTP request in seconds.
|
||||||
|
# Default to 0 (never times out).
|
||||||
|
attr_accessor :timeout
|
||||||
|
|
||||||
### TLS/SSL
|
### TLS/SSL
|
||||||
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
||||||
# Default to true.
|
# Default to true.
|
||||||
@ -93,6 +97,7 @@ module Petstore
|
|||||||
@base_path = '/v2'
|
@base_path = '/v2'
|
||||||
@api_key = {}
|
@api_key = {}
|
||||||
@api_key_prefix = {}
|
@api_key_prefix = {}
|
||||||
|
@timeout = 0
|
||||||
@verify_ssl = true
|
@verify_ssl = true
|
||||||
@cert_file = nil
|
@cert_file = nil
|
||||||
@key_file = nil
|
@key_file = nil
|
||||||
|
@ -59,7 +59,7 @@ describe Petstore::ApiClient do
|
|||||||
c.api_key['api_key'] = 'special-key2'
|
c.api_key['api_key'] = 'special-key2'
|
||||||
end
|
end
|
||||||
api_client2 = Petstore::ApiClient.new(config2)
|
api_client2 = Petstore::ApiClient.new(config2)
|
||||||
|
|
||||||
auth_names = ['api_key', 'unknown']
|
auth_names = ['api_key', 'unknown']
|
||||||
|
|
||||||
header_params = {}
|
header_params = {}
|
||||||
@ -82,7 +82,7 @@ describe Petstore::ApiClient do
|
|||||||
end
|
end
|
||||||
|
|
||||||
api_client = Petstore::ApiClient.new
|
api_client = Petstore::ApiClient.new
|
||||||
|
|
||||||
header_params = {}
|
header_params = {}
|
||||||
query_params = {}
|
query_params = {}
|
||||||
auth_names = ['api_key', 'unknown']
|
auth_names = ['api_key', 'unknown']
|
||||||
@ -92,6 +92,25 @@ describe Petstore::ApiClient do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "timeout in #build_request" do
|
||||||
|
let(:config) { Petstore::Configuration.new }
|
||||||
|
let(:api_client) { Petstore::ApiClient.new(config) }
|
||||||
|
|
||||||
|
it "defaults to 0" do
|
||||||
|
Petstore::Configuration.default.timeout.should == 0
|
||||||
|
config.timeout.should == 0
|
||||||
|
|
||||||
|
request = api_client.build_request(:get, '/test')
|
||||||
|
request.options[:timeout].should == 0
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can be customized" do
|
||||||
|
config.timeout = 100
|
||||||
|
request = api_client.build_request(:get, '/test')
|
||||||
|
request.options[:timeout].should == 100
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#deserialize" do
|
describe "#deserialize" do
|
||||||
it "handles Hash<String, String>" do
|
it "handles Hash<String, String>" do
|
||||||
api_client = Petstore::ApiClient.new
|
api_client = Petstore::ApiClient.new
|
||||||
|
Loading…
x
Reference in New Issue
Block a user