diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache index 3e65c72e932..504c4532560 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache @@ -47,10 +47,18 @@ module {{moduleName}} end unless response.success? - fail ApiError.new(:code => response.code, - :response_headers => response.headers, - :response_body => response.body), - response.status_message + if response.timed_out? + fail ApiError.new('Connection timed out') + elsif response.code == 0 + # Errors from libcurl will be made visible here + fail ApiError.new(:code => 0, + :message => response.return_message) + else + fail ApiError.new(:code => response.code, + :response_headers => response.headers, + :response_body => response.body), + response.status_message + end end if opts[:return_type] diff --git a/samples/client/petstore-security-test/ruby/README.md b/samples/client/petstore-security-test/ruby/README.md index 905a00d2242..29455303d53 100644 --- a/samples/client/petstore-security-test/ruby/README.md +++ b/samples/client/petstore-security-test/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r - Package version: 1.0.0 -- Build date: 2016-07-14T18:21:54.437+08:00 +- Build date: 2016-08-29T14:24:34.432-07:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -87,18 +87,18 @@ Class | Method | HTTP request | Description ## Documentation for Authorization -### api_key - -- **Type**: API key -- **API key parameter name**: api_key */ ' " =end -- \r\n \n \r -- **Location**: HTTP header - ### petstore_auth - **Type**: OAuth - **Flow**: implicit - **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog - **Scopes**: - - write:pets: modify pets in your account */ ' " =end -- \r\n \n \r - - read:pets: read your pets */ ' " =end -- \r\n \n \r + - write:pets: modify pets in your account */ ' \" =_end -- \\r\\n \\n \\r + - read:pets: read your pets */ ' \" =_end -- \\r\\n \\n \\r + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key */ ' " =end -- \r\n \n \r +- **Location**: HTTP header diff --git a/samples/client/petstore-security-test/ruby/lib/petstore/api_client.rb b/samples/client/petstore-security-test/ruby/lib/petstore/api_client.rb index a198cd74008..db344d4e1f0 100644 --- a/samples/client/petstore-security-test/ruby/lib/petstore/api_client.rb +++ b/samples/client/petstore-security-test/ruby/lib/petstore/api_client.rb @@ -66,10 +66,18 @@ def call_api(http_method, path, opts = {}) end unless response.success? - fail ApiError.new(:code => response.code, - :response_headers => response.headers, - :response_body => response.body), - response.status_message + if response.timed_out? + fail ApiError.new('Connection timed out') + elsif response.code == 0 + # Errors from libcurl will be made visible here + fail ApiError.new(:code => 0, + :message => response.return_message) + else + fail ApiError.new(:code => response.code, + :response_headers => response.headers, + :response_body => response.body), + response.status_message + end end if opts[:return_type] @@ -288,7 +296,7 @@ def build_request_body(header_params, form_params, body) # Update hearder and query params based on authentication settings. # # @param [Hash] header_params Header parameters - # @param [Hash] form_params Query parameters + # @param [Hash] query_params Query parameters # @param [String] auth_names Authentication scheme name def update_params_for_auth!(header_params, query_params, auth_names) Array(auth_names).each do |auth_name| diff --git a/samples/client/petstore-security-test/ruby/lib/petstore/configuration.rb b/samples/client/petstore-security-test/ruby/lib/petstore/configuration.rb index 86c40326971..57ecfab010b 100644 --- a/samples/client/petstore-security-test/ruby/lib/petstore/configuration.rb +++ b/samples/client/petstore-security-test/ruby/lib/petstore/configuration.rb @@ -201,13 +201,6 @@ def basic_auth_token # Returns Auth Settings hash for api client. def auth_settings { - 'api_key' => - { - type: 'api_key', - in: 'header', - key: 'api_key */ ' " =end -- \r\n \n \r', - value: api_key_with_prefix('api_key */ ' " =end -- \r\n \n \r') - }, 'petstore_auth' => { type: 'oauth2', @@ -215,6 +208,13 @@ def auth_settings key: 'Authorization', value: "Bearer #{access_token}" }, + 'api_key' => + { + type: 'api_key', + in: 'header', + key: 'api_key */ ' " =end -- \r\n \n \r', + value: api_key_with_prefix('api_key */ ' " =end -- \r\n \n \r') + }, } end end diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 3d5441c5ab2..8f12077a335 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-08-22T16:46:39.641+08:00 +- Build date: 2016-08-29T14:24:29.182-07:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -137,12 +137,6 @@ Class | Method | HTTP request | Description ## Documentation for Authorization -### api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - ### petstore_auth - **Type**: OAuth @@ -156,3 +150,9 @@ Class | Method | HTTP request | Description - **Type**: HTTP basic authentication +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + diff --git a/samples/client/petstore/ruby/lib/petstore/api_client.rb b/samples/client/petstore/ruby/lib/petstore/api_client.rb index 52ba90b2082..23dbcd9c439 100644 --- a/samples/client/petstore/ruby/lib/petstore/api_client.rb +++ b/samples/client/petstore/ruby/lib/petstore/api_client.rb @@ -66,10 +66,18 @@ def call_api(http_method, path, opts = {}) end unless response.success? - fail ApiError.new(:code => response.code, - :response_headers => response.headers, - :response_body => response.body), - response.status_message + if response.timed_out? + fail ApiError.new('Connection timed out') + elsif response.code == 0 + # Errors from libcurl will be made visible here + fail ApiError.new(:code => 0, + :message => response.return_message) + else + fail ApiError.new(:code => response.code, + :response_headers => response.headers, + :response_body => response.body), + response.status_message + end end if opts[:return_type] diff --git a/samples/client/petstore/ruby/lib/petstore/configuration.rb b/samples/client/petstore/ruby/lib/petstore/configuration.rb index 2b2d15dff4d..04679eac77b 100644 --- a/samples/client/petstore/ruby/lib/petstore/configuration.rb +++ b/samples/client/petstore/ruby/lib/petstore/configuration.rb @@ -201,13 +201,6 @@ def basic_auth_token # Returns Auth Settings hash for api client. def auth_settings { - 'api_key' => - { - type: 'api_key', - in: 'header', - key: 'api_key', - value: api_key_with_prefix('api_key') - }, 'petstore_auth' => { type: 'oauth2', @@ -222,6 +215,13 @@ def auth_settings key: 'Authorization', value: basic_auth_token }, + 'api_key' => + { + type: 'api_key', + in: 'header', + key: 'api_key', + value: api_key_with_prefix('api_key') + }, } end end