[Ruby] Add params_encoding configuration to be passed to api_client's request options.

This commit is contained in:
Cliffano Subagio 2016-06-28 15:22:34 +10:00
parent 12cd0c55a0
commit af77d94750
40 changed files with 123 additions and 86 deletions

View File

@ -86,6 +86,7 @@ module {{moduleName}}
:method => http_method, :method => http_method,
:headers => header_params, :headers => header_params,
:params => query_params, :params => query_params,
:params_encoding => @config.params_encoding,
:timeout => @config.timeout, :timeout => @config.timeout,
:ssl_verifypeer => @config.verify_ssl, :ssl_verifypeer => @config.verify_ssl,
:sslcert => @config.cert_file, :sslcert => @config.cert_file,

View File

@ -90,6 +90,25 @@ describe {{moduleName}}::ApiClient do
end end
end end
describe "params_encoding in #build_request" do
let(:config) { {{moduleName}}::Configuration.new }
let(:api_client) { {{moduleName}}::ApiClient.new(config) }
it "defaults to nil" do
expect({{moduleName}}::Configuration.default.params_encoding).to eq(nil)
expect(config.params_encoding).to eq(nil)
request = api_client.build_request(:get, '/test')
expect(request.options[:params_encoding]).to eq(nil)
end
it "can be customized" do
config.params_encoding = :multi
request = api_client.build_request(:get, '/test')
expect(request.options[:params_encoding]).to eq(:multi)
end
end
describe "timeout in #build_request" do describe "timeout in #build_request" do
let(:config) { {{moduleName}}::Configuration.new } let(:config) { {{moduleName}}::Configuration.new }
let(:api_client) { {{moduleName}}::ApiClient.new(config) } let(:api_client) { {{moduleName}}::ApiClient.new(config) }

View File

@ -77,6 +77,13 @@ module {{moduleName}}
# @return [true, false] # @return [true, false]
attr_accessor :verify_ssl attr_accessor :verify_ssl
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
# Default to nil.
#
# @see The params_encoding option of Ethon. Related source code:
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
attr_accessor :params_encoding
# Set this to customize the certificate file to verify the peer. # Set this to customize the certificate file to verify the peer.
# #
# @return [String] the path to the certificate file # @return [String] the path to the certificate file
@ -103,6 +110,7 @@ module {{moduleName}}
@api_key_prefix = {} @api_key_prefix = {}
@timeout = 0 @timeout = 0
@verify_ssl = true @verify_ssl = true
@params_encoding = nil
@cert_file = nil @cert_file = nil
@key_file = nil @key_file = nil
@debugging = false @debugging = false

View File

@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/
- API version: 1.0.0 - API version: 1.0.0
- Package version: 1.0.0 - Package version: 1.0.0
- Build date: 2016-06-26T19:08:46.043+08:00 - Build date: 2016-06-28T15:19:55.521+10:00
- Build package: class io.swagger.codegen.languages.RubyClientCodegen - Build package: class io.swagger.codegen.languages.RubyClientCodegen
## Installation ## Installation
@ -148,12 +148,6 @@ Class | Method | HTTP request | Description
## Documentation for Authorization ## Documentation for Authorization
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
### petstore_auth ### petstore_auth
- **Type**: OAuth - **Type**: OAuth
@ -163,3 +157,9 @@ Class | Method | HTTP request | Description
- write:pets: modify pets in your account - write:pets: modify pets in your account
- read:pets: read your pets - read:pets: read your pets
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
@ -103,6 +103,7 @@ module Petstore
:method => http_method, :method => http_method,
:headers => header_params, :headers => header_params,
:params => query_params, :params => query_params,
:params_encoding => @config.params_encoding,
:timeout => @config.timeout, :timeout => @config.timeout,
:ssl_verifypeer => @config.verify_ssl, :ssl_verifypeer => @config.verify_ssl,
:sslcert => @config.cert_file, :sslcert => @config.cert_file,

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
@ -96,6 +96,13 @@ module Petstore
# @return [true, false] # @return [true, false]
attr_accessor :verify_ssl attr_accessor :verify_ssl
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
# Default to nil.
#
# @see The params_encoding option of Ethon. Related source code:
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
attr_accessor :params_encoding
# Set this to customize the certificate file to verify the peer. # Set this to customize the certificate file to verify the peer.
# #
# @return [String] the path to the certificate file # @return [String] the path to the certificate file
@ -122,6 +129,7 @@ module Petstore
@api_key_prefix = {} @api_key_prefix = {}
@timeout = 0 @timeout = 0
@verify_ssl = true @verify_ssl = true
@params_encoding = nil
@cert_file = nil @cert_file = nil
@key_file = nil @key_file = nil
@debugging = false @debugging = false
@ -180,13 +188,6 @@ module Petstore
# Returns Auth Settings hash for api client. # Returns Auth Settings hash for api client.
def auth_settings def auth_settings
{ {
'api_key' =>
{
type: 'api_key',
in: 'header',
key: 'api_key',
value: api_key_with_prefix('api_key')
},
'petstore_auth' => 'petstore_auth' =>
{ {
type: 'oauth2', type: 'oauth2',
@ -194,6 +195,13 @@ module Petstore
key: 'Authorization', key: 'Authorization',
value: "Bearer #{access_token}" value: "Bearer #{access_token}"
}, },
'api_key' =>
{
type: 'api_key',
in: 'header',
key: 'api_key',
value: api_key_with_prefix('api_key')
},
} }
end end
end end

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,7 +1,7 @@
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io

View File

@ -1,9 +1,9 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
# #
=begin =begin
Swagger Petstore #Swagger Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io