Return data before response status code and headers

This commit is contained in:
xhh 2015-12-07 16:10:24 +08:00
parent 66112d9eb5
commit 07de03c09b
7 changed files with 104 additions and 100 deletions

View File

@ -17,7 +17,7 @@ module {{moduleName}}
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}
{{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}]
def {{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
{{#returnType}}status_code, headers, data = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts)
{{#returnType}}data, status_code, headers = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts)
{{#returnType}}return data{{/returnType}}{{^returnType}}return nil{{/returnType}}
end
@ -26,7 +26,7 @@ module {{moduleName}}
{{#allParams}}{{#required}} # @param {{paramName}} {{description}}
{{/required}}{{/allParams}} # @param [Hash] opts the optional parameters
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}
{{/required}}{{/allParams}} # @return [Array<Fixnum, Hash, {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}>] response status code, response headers and {{#returnType}}{{{returnType}}} data{{/returnType}}{{^returnType}}nil{{/returnType}}
{{/required}}{{/allParams}} # @return [Array<({{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}, Fixnum, Hash)>] {{#returnType}}{{{returnType}}} data{{/returnType}}{{^returnType}}nil{{/returnType}}, response status code and response headers
def {{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: {{classname}}#{{operationId}} ..."
@ -74,7 +74,7 @@ module {{moduleName}}
{{/bodyParam}}
auth_names = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}]
status_code, headers, data = @api_client.call_api(:{{httpMethod}}, path,
data, status_code, headers = @api_client.call_api(:{{httpMethod}}, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -82,9 +82,9 @@ module {{moduleName}}
:auth_names => auth_names{{#returnType}},
:return_type => '{{{returnType}}}'{{/returnType}})
if Configuration.debugging
Configuration.logger.debug "API called: {{classname}}#{{operationId}}\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: {{classname}}#{{operationId}}\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
{{/operation}}
end

View File

@ -25,8 +25,10 @@ module {{moduleName}}
}
end
# Call an API with given options and an array of 3 elements:
# response status code, response headers and the data deserialized from response body (could be nil).
# Call an API with given options.
#
# @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
# the data deserialized from response body (could be nil), response status code and response headers.
def call_api(http_method, path, opts = {})
request = build_request(http_method, path, opts)
response = request.run
@ -47,7 +49,7 @@ module {{moduleName}}
else
data = nil
end
return response.code, response.headers, data
return data, response.code, response.headers
end
def build_request(http_method, path, opts = {})

View File

@ -22,7 +22,7 @@ module Petstore
#
# @param [Hash] opts the optional parameters
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_pet_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#update_pet ..."
@ -53,16 +53,16 @@ module Petstore
auth_names = ['petstore_auth']
status_code, headers, data = @api_client.call_api(:PUT, path,
data, status_code, headers = @api_client.call_api(:PUT, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#update_pet\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: PetApi#update_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Add a new pet to the store
@ -79,7 +79,7 @@ module Petstore
#
# @param [Hash] opts the optional parameters
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def add_pet_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#add_pet ..."
@ -110,16 +110,16 @@ module Petstore
auth_names = ['petstore_auth']
status_code, headers, data = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#add_pet\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: PetApi#add_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Finds Pets by status
@ -128,7 +128,7 @@ module Petstore
# @option opts [Array<String>] :status Status values that need to be considered for filter
# @return [Array<Pet>]
def find_pets_by_status(opts = {})
status_code, headers, data = find_pets_by_status_with_http_info(opts)
data, status_code, headers = find_pets_by_status_with_http_info(opts)
return data
end
@ -136,7 +136,7 @@ module Petstore
# Multiple status values can be provided with comma seperated strings
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :status Status values that need to be considered for filter
# @return [Array<Fixnum, Hash, Array<Pet>>] response status code, response headers and Array<Pet> data
# @return [Array<(Array<Pet>, Fixnum, Hash)>] Array<Pet> data, response status code and response headers
def find_pets_by_status_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#find_pets_by_status ..."
@ -168,7 +168,7 @@ module Petstore
auth_names = ['petstore_auth']
status_code, headers, data = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -176,9 +176,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'Array<Pet>')
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#find_pets_by_status\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: PetApi#find_pets_by_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Finds Pets by tags
@ -187,7 +187,7 @@ module Petstore
# @option opts [Array<String>] :tags Tags to filter by
# @return [Array<Pet>]
def find_pets_by_tags(opts = {})
status_code, headers, data = find_pets_by_tags_with_http_info(opts)
data, status_code, headers = find_pets_by_tags_with_http_info(opts)
return data
end
@ -195,7 +195,7 @@ module Petstore
# Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :tags Tags to filter by
# @return [Array<Fixnum, Hash, Array<Pet>>] response status code, response headers and Array<Pet> data
# @return [Array<(Array<Pet>, Fixnum, Hash)>] Array<Pet> data, response status code and response headers
def find_pets_by_tags_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#find_pets_by_tags ..."
@ -227,7 +227,7 @@ module Petstore
auth_names = ['petstore_auth']
status_code, headers, data = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -235,9 +235,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'Array<Pet>')
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#find_pets_by_tags\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: PetApi#find_pets_by_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Find pet by ID
@ -246,7 +246,7 @@ module Petstore
# @param [Hash] opts the optional parameters
# @return [Pet]
def get_pet_by_id(pet_id, opts = {})
status_code, headers, data = get_pet_by_id_with_http_info(pet_id, opts)
data, status_code, headers = get_pet_by_id_with_http_info(pet_id, opts)
return data
end
@ -254,7 +254,7 @@ module Petstore
# Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
# @param pet_id ID of pet that needs to be fetched
# @param [Hash] opts the optional parameters
# @return [Array<Fixnum, Hash, Pet>] response status code, response headers and Pet data
# @return [Array<(Pet, Fixnum, Hash)>] Pet data, response status code and response headers
def get_pet_by_id_with_http_info(pet_id, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#get_pet_by_id ..."
@ -288,7 +288,7 @@ module Petstore
auth_names = ['api_key']
status_code, headers, data = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -296,9 +296,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'Pet')
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#get_pet_by_id\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: PetApi#get_pet_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Updates a pet in the store with form data
@ -319,7 +319,7 @@ module Petstore
# @param [Hash] opts the optional parameters
# @option opts [String] :name Updated name of the pet
# @option opts [String] :status Updated status of the pet
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_pet_with_form_with_http_info(pet_id, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#update_pet_with_form ..."
@ -355,16 +355,16 @@ module Petstore
auth_names = ['petstore_auth']
status_code, headers, data = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#update_pet_with_form\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: PetApi#update_pet_with_form\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Deletes a pet
@ -383,7 +383,7 @@ module Petstore
# @param pet_id Pet id to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :api_key
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_pet_with_http_info(pet_id, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#delete_pet ..."
@ -418,16 +418,16 @@ module Petstore
auth_names = ['petstore_auth']
status_code, headers, data = @api_client.call_api(:DELETE, path,
data, status_code, headers = @api_client.call_api(:DELETE, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#delete_pet\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: PetApi#delete_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# uploads an image
@ -448,7 +448,7 @@ module Petstore
# @param [Hash] opts the optional parameters
# @option opts [String] :additional_metadata Additional data to pass to server
# @option opts [File] :file file to upload
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def upload_file_with_http_info(pet_id, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#upload_file ..."
@ -484,16 +484,16 @@ module Petstore
auth_names = ['petstore_auth']
status_code, headers, data = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#upload_file\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: PetApi#upload_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
end
end

View File

@ -13,14 +13,14 @@ module Petstore
# @param [Hash] opts the optional parameters
# @return [Hash<String, Integer>]
def get_inventory(opts = {})
status_code, headers, data = get_inventory_with_http_info(opts)
data, status_code, headers = get_inventory_with_http_info(opts)
return data
end
# Returns pet inventories by status
# Returns a map of status codes to quantities
# @param [Hash] opts the optional parameters
# @return [Array<Fixnum, Hash, Hash<String, Integer>>] response status code, response headers and Hash<String, Integer> data
# @return [Array<(Hash<String, Integer>, Fixnum, Hash)>] Hash<String, Integer> data, response status code and response headers
def get_inventory_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: StoreApi#get_inventory ..."
@ -51,7 +51,7 @@ module Petstore
auth_names = ['api_key']
status_code, headers, data = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -59,9 +59,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'Hash<String, Integer>')
if Configuration.debugging
Configuration.logger.debug "API called: StoreApi#get_inventory\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: StoreApi#get_inventory\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Place an order for a pet
@ -70,7 +70,7 @@ module Petstore
# @option opts [Order] :body order placed for purchasing the pet
# @return [Order]
def place_order(opts = {})
status_code, headers, data = place_order_with_http_info(opts)
data, status_code, headers = place_order_with_http_info(opts)
return data
end
@ -78,7 +78,7 @@ module Petstore
#
# @param [Hash] opts the optional parameters
# @option opts [Order] :body order placed for purchasing the pet
# @return [Array<Fixnum, Hash, Order>] response status code, response headers and Order data
# @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers
def place_order_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: StoreApi#place_order ..."
@ -109,7 +109,7 @@ module Petstore
auth_names = []
status_code, headers, data = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -117,9 +117,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'Order')
if Configuration.debugging
Configuration.logger.debug "API called: StoreApi#place_order\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: StoreApi#place_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Find purchase order by ID
@ -128,7 +128,7 @@ module Petstore
# @param [Hash] opts the optional parameters
# @return [Order]
def get_order_by_id(order_id, opts = {})
status_code, headers, data = get_order_by_id_with_http_info(order_id, opts)
data, status_code, headers = get_order_by_id_with_http_info(order_id, opts)
return data
end
@ -136,7 +136,7 @@ module Petstore
# For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
# @param order_id ID of pet that needs to be fetched
# @param [Hash] opts the optional parameters
# @return [Array<Fixnum, Hash, Order>] response status code, response headers and Order data
# @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers
def get_order_by_id_with_http_info(order_id, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: StoreApi#get_order_by_id ..."
@ -170,7 +170,7 @@ module Petstore
auth_names = []
status_code, headers, data = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -178,9 +178,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'Order')
if Configuration.debugging
Configuration.logger.debug "API called: StoreApi#get_order_by_id\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: StoreApi#get_order_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Delete purchase order by ID
@ -197,7 +197,7 @@ module Petstore
# For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
# @param order_id ID of the order that needs to be deleted
# @param [Hash] opts the optional parameters
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_order_with_http_info(order_id, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: StoreApi#delete_order ..."
@ -231,16 +231,16 @@ module Petstore
auth_names = []
status_code, headers, data = @api_client.call_api(:DELETE, path,
data, status_code, headers = @api_client.call_api(:DELETE, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: StoreApi#delete_order\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: StoreApi#delete_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
end
end

View File

@ -22,7 +22,7 @@ module Petstore
# This can only be done by the logged in user.
# @param [Hash] opts the optional parameters
# @option opts [User] :body Created user object
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def create_user_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#create_user ..."
@ -53,16 +53,16 @@ module Petstore
auth_names = []
status_code, headers, data = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#create_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: UserApi#create_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Creates list of users with given input array
@ -79,7 +79,7 @@ module Petstore
#
# @param [Hash] opts the optional parameters
# @option opts [Array<User>] :body List of user object
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def create_users_with_array_input_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#create_users_with_array_input ..."
@ -110,16 +110,16 @@ module Petstore
auth_names = []
status_code, headers, data = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#create_users_with_array_input\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: UserApi#create_users_with_array_input\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Creates list of users with given input array
@ -136,7 +136,7 @@ module Petstore
#
# @param [Hash] opts the optional parameters
# @option opts [Array<User>] :body List of user object
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def create_users_with_list_input_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#create_users_with_list_input ..."
@ -167,16 +167,16 @@ module Petstore
auth_names = []
status_code, headers, data = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#create_users_with_list_input\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: UserApi#create_users_with_list_input\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Logs user into the system
@ -186,7 +186,7 @@ module Petstore
# @option opts [String] :password The password for login in clear text
# @return [String]
def login_user(opts = {})
status_code, headers, data = login_user_with_http_info(opts)
data, status_code, headers = login_user_with_http_info(opts)
return data
end
@ -195,7 +195,7 @@ module Petstore
# @param [Hash] opts the optional parameters
# @option opts [String] :username The user name for login
# @option opts [String] :password The password for login in clear text
# @return [Array<Fixnum, Hash, String>] response status code, response headers and String data
# @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers
def login_user_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#login_user ..."
@ -228,7 +228,7 @@ module Petstore
auth_names = []
status_code, headers, data = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -236,9 +236,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'String')
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#login_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: UserApi#login_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Logs out current logged in user session
@ -253,7 +253,7 @@ module Petstore
# Logs out current logged in user session
#
# @param [Hash] opts the optional parameters
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def logout_user_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#logout_user ..."
@ -284,16 +284,16 @@ module Petstore
auth_names = []
status_code, headers, data = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#logout_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: UserApi#logout_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Get user by user name
@ -302,7 +302,7 @@ module Petstore
# @param [Hash] opts the optional parameters
# @return [User]
def get_user_by_name(username, opts = {})
status_code, headers, data = get_user_by_name_with_http_info(username, opts)
data, status_code, headers = get_user_by_name_with_http_info(username, opts)
return data
end
@ -310,7 +310,7 @@ module Petstore
#
# @param username The name that needs to be fetched. Use user1 for testing.
# @param [Hash] opts the optional parameters
# @return [Array<Fixnum, Hash, User>] response status code, response headers and User data
# @return [Array<(User, Fixnum, Hash)>] User data, response status code and response headers
def get_user_by_name_with_http_info(username, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#get_user_by_name ..."
@ -344,7 +344,7 @@ module Petstore
auth_names = []
status_code, headers, data = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -352,9 +352,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'User')
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#get_user_by_name\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: UserApi#get_user_by_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Updated user
@ -373,7 +373,7 @@ module Petstore
# @param username name that need to be deleted
# @param [Hash] opts the optional parameters
# @option opts [User] :body Updated user object
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_user_with_http_info(username, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#update_user ..."
@ -407,16 +407,16 @@ module Petstore
auth_names = []
status_code, headers, data = @api_client.call_api(:PUT, path,
data, status_code, headers = @api_client.call_api(:PUT, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#update_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: UserApi#update_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
# Delete user
@ -433,7 +433,7 @@ module Petstore
# This can only be done by the logged in user.
# @param username The name that needs to be deleted
# @param [Hash] opts the optional parameters
# @return [Array<Fixnum, Hash, nil>] response status code, response headers and nil
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_user_with_http_info(username, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#delete_user ..."
@ -467,16 +467,16 @@ module Petstore
auth_names = []
status_code, headers, data = @api_client.call_api(:DELETE, path,
data, status_code, headers = @api_client.call_api(:DELETE, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#delete_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}"
Configuration.logger.debug "API called: UserApi#delete_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return status_code, headers, data
return data, status_code, headers
end
end
end

View File

@ -25,8 +25,10 @@ module Petstore
}
end
# Call an API with given options and an array of 3 elements:
# response status code, response headers and the data deserialized from response body (could be nil).
# Call an API with given options.
#
# @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
# the data deserialized from response body (could be nil), response status code and response headers.
def call_api(http_method, path, opts = {})
request = build_request(http_method, path, opts)
response = request.run
@ -47,7 +49,7 @@ module Petstore
else
data = nil
end
return response.code, response.headers, data
return data, response.code, response.headers
end
def build_request(http_method, path, opts = {})

View File

@ -51,7 +51,7 @@ describe "Pet" do
end
it "should fetch a pet object with http info" do
status_code, headers, pet = @pet_api.get_pet_by_id_with_http_info(10002)
pet, status_code, headers = @pet_api.get_pet_by_id_with_http_info(10002)
status_code.should == 200
headers['Content-Type'].should == 'application/json'
pet.should be_a(Petstore::Pet)