forked from loafle/openapi-generator-original
Regenerate petstore ruby sample
This commit is contained in:
parent
6eaaa5cc69
commit
ab4975b7f1
@ -7,6 +7,7 @@ require 'swagger_client/swagger/response'
|
|||||||
require 'swagger_client/swagger/version'
|
require 'swagger_client/swagger/version'
|
||||||
|
|
||||||
# Models
|
# Models
|
||||||
|
require 'swagger_client/models/base_object'
|
||||||
require 'swagger_client/models/user'
|
require 'swagger_client/models/user'
|
||||||
require 'swagger_client/models/category'
|
require 'swagger_client/models/category'
|
||||||
require 'swagger_client/models/pet'
|
require 'swagger_client/models/pet'
|
||||||
@ -21,4 +22,4 @@ require 'swagger_client/api/store_api'
|
|||||||
module SwaggerClient
|
module SwaggerClient
|
||||||
# Initialize the default configuration
|
# Initialize the default configuration
|
||||||
Swagger.configuration ||= Swagger::Configuration.new
|
Swagger.configuration ||= Swagger::Configuration.new
|
||||||
end
|
end
|
||||||
|
@ -11,7 +11,7 @@ module SwaggerClient
|
|||||||
# @option opts [Pet] :body Pet object that needs to be added to the store
|
# @option opts [Pet] :body Pet object that needs to be added to the store
|
||||||
# @return void
|
# @return void
|
||||||
def self.update_pet(opts = {})
|
def self.update_pet(opts = {})
|
||||||
# verify existence of params
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/pet".sub('{format}','json')
|
path = "/pet".sub('{format}','json')
|
||||||
@ -22,40 +22,23 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = ['application/json', 'application/xml', ]
|
_header_content_type = ['application/json', 'application/xml', ]
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = Swagger::Request.object_to_http_body(opts[:'body'])
|
||||||
_body_param = opts[:'body']
|
|
||||||
if _body_param != nil
|
|
||||||
if _body_param.is_a?(Array)
|
|
||||||
_array = Array.new
|
|
||||||
_body_param.each do |item|
|
|
||||||
if item.respond_to?(:to_body)
|
|
||||||
_array.push item.to_body
|
|
||||||
else
|
|
||||||
_array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = _array
|
|
||||||
else
|
|
||||||
if _body_param.respond_to?(:to_body)
|
|
||||||
post_body = _body_param.to_body
|
|
||||||
else
|
|
||||||
post_body = _body_param
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a new pet to the store
|
# Add a new pet to the store
|
||||||
#
|
#
|
||||||
@ -63,7 +46,7 @@ module SwaggerClient
|
|||||||
# @option opts [Pet] :body Pet object that needs to be added to the store
|
# @option opts [Pet] :body Pet object that needs to be added to the store
|
||||||
# @return void
|
# @return void
|
||||||
def self.add_pet(opts = {})
|
def self.add_pet(opts = {})
|
||||||
# verify existence of params
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/pet".sub('{format}','json')
|
path = "/pet".sub('{format}','json')
|
||||||
@ -74,40 +57,23 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = ['application/json', 'application/xml', ]
|
_header_content_type = ['application/json', 'application/xml', ]
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = Swagger::Request.object_to_http_body(opts[:'body'])
|
||||||
_body_param = opts[:'body']
|
|
||||||
if _body_param != nil
|
|
||||||
if _body_param.is_a?(Array)
|
|
||||||
_array = Array.new
|
|
||||||
_body_param.each do |item|
|
|
||||||
if item.respond_to?(:to_body)
|
|
||||||
_array.push item.to_body
|
|
||||||
else
|
|
||||||
_array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = _array
|
|
||||||
else
|
|
||||||
if _body_param.respond_to?(:to_body)
|
|
||||||
post_body = _body_param.to_body
|
|
||||||
else
|
|
||||||
post_body = _body_param
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
end
|
end
|
||||||
|
|
||||||
# Finds Pets by status
|
# Finds Pets by status
|
||||||
# Multiple status values can be provided with comma seperated strings
|
# Multiple status values can be provided with comma seperated strings
|
||||||
@ -115,7 +81,7 @@ module SwaggerClient
|
|||||||
# @option opts [array[string]] :status Status values that need to be considered for filter
|
# @option opts [array[string]] :status Status values that need to be considered for filter
|
||||||
# @return array[Pet]
|
# @return array[Pet]
|
||||||
def self.find_pets_by_status(opts = {})
|
def self.find_pets_by_status(opts = {})
|
||||||
# verify existence of params
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/pet/findByStatus".sub('{format}','json')
|
path = "/pet/findByStatus".sub('{format}','json')
|
||||||
@ -127,21 +93,24 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
response.map {|response| Pet.new(response) }
|
response.map {|response| obj = Pet.new() and obj.build_from_hash(response) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Finds Pets by tags
|
# Finds Pets by tags
|
||||||
# Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
# Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||||
@ -149,7 +118,7 @@ module SwaggerClient
|
|||||||
# @option opts [array[string]] :tags Tags to filter by
|
# @option opts [array[string]] :tags Tags to filter by
|
||||||
# @return array[Pet]
|
# @return array[Pet]
|
||||||
def self.find_pets_by_tags(opts = {})
|
def self.find_pets_by_tags(opts = {})
|
||||||
# verify existence of params
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/pet/findByTags".sub('{format}','json')
|
path = "/pet/findByTags".sub('{format}','json')
|
||||||
@ -161,21 +130,24 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
response.map {|response| Pet.new(response) }
|
response.map {|response| obj = Pet.new() and obj.build_from_hash(response) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Find pet by ID
|
# Find pet by ID
|
||||||
# Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
# Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||||
@ -183,8 +155,10 @@ module SwaggerClient
|
|||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return Pet
|
# @return Pet
|
||||||
def self.get_pet_by_id(pet_id, opts = {})
|
def self.get_pet_by_id(pet_id, opts = {})
|
||||||
# verify existence of params
|
|
||||||
raise "pet_id is required" if pet_id.nil?
|
# verify the required parameter 'pet_id' is set
|
||||||
|
raise "Missing the required parameter 'pet_id' when calling get_pet_by_id" if pet_id.nil?
|
||||||
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
||||||
@ -195,21 +169,24 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
Pet.new(response)
|
obj = Pet.new() and obj.build_from_hash(response)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Updates a pet in the store with form data
|
# Updates a pet in the store with form data
|
||||||
#
|
#
|
||||||
@ -219,8 +196,10 @@ module SwaggerClient
|
|||||||
# @option opts [string] :status Updated status of the pet
|
# @option opts [string] :status Updated status of the pet
|
||||||
# @return void
|
# @return void
|
||||||
def self.update_pet_with_form(pet_id, opts = {})
|
def self.update_pet_with_form(pet_id, opts = {})
|
||||||
# verify existence of params
|
|
||||||
raise "pet_id is required" if pet_id.nil?
|
# verify the required parameter 'pet_id' is set
|
||||||
|
raise "Missing the required parameter 'pet_id' when calling update_pet_with_form" if pet_id.nil?
|
||||||
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
||||||
@ -231,11 +210,13 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = ['application/x-www-form-urlencoded', ]
|
_header_content_type = ['application/x-www-form-urlencoded', ]
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
@ -244,9 +225,10 @@ module SwaggerClient
|
|||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deletes a pet
|
# Deletes a pet
|
||||||
#
|
#
|
||||||
@ -255,8 +237,10 @@ module SwaggerClient
|
|||||||
# @option opts [string] :api_key
|
# @option opts [string] :api_key
|
||||||
# @return void
|
# @return void
|
||||||
def self.delete_pet(pet_id, opts = {})
|
def self.delete_pet(pet_id, opts = {})
|
||||||
# verify existence of params
|
|
||||||
raise "pet_id is required" if pet_id.nil?
|
# verify the required parameter 'pet_id' is set
|
||||||
|
raise "Missing the required parameter 'pet_id' when calling delete_pet" if pet_id.nil?
|
||||||
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
||||||
@ -267,11 +251,13 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
header_params[:'api_key'] = opts[:'api_key'] if opts[:'api_key']
|
header_params[:'api_key'] = opts[:'api_key'] if opts[:'api_key']
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
@ -279,9 +265,10 @@ module SwaggerClient
|
|||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
end
|
end
|
||||||
|
|
||||||
# uploads an image
|
# uploads an image
|
||||||
#
|
#
|
||||||
@ -291,8 +278,10 @@ module SwaggerClient
|
|||||||
# @option opts [file] :file file to upload
|
# @option opts [file] :file file to upload
|
||||||
# @return void
|
# @return void
|
||||||
def self.upload_file(pet_id, opts = {})
|
def self.upload_file(pet_id, opts = {})
|
||||||
# verify existence of params
|
|
||||||
raise "pet_id is required" if pet_id.nil?
|
# verify the required parameter 'pet_id' is set
|
||||||
|
raise "Missing the required parameter 'pet_id' when calling upload_file" if pet_id.nil?
|
||||||
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
||||||
@ -303,11 +292,13 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = ['multipart/form-data', ]
|
_header_content_type = ['multipart/form-data', ]
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
@ -316,8 +307,9 @@ module SwaggerClient
|
|||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
@ -10,7 +10,7 @@ module SwaggerClient
|
|||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return map[string,int]
|
# @return map[string,int]
|
||||||
def self.get_inventory(opts = {})
|
def self.get_inventory(opts = {})
|
||||||
# verify existence of params
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/store/inventory".sub('{format}','json')
|
path = "/store/inventory".sub('{format}','json')
|
||||||
@ -21,21 +21,24 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
response.map {|response| map.new(response) }
|
response.map {|response| obj = map.new() and obj.build_from_hash(response) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Place an order for a pet
|
# Place an order for a pet
|
||||||
#
|
#
|
||||||
@ -43,7 +46,7 @@ module SwaggerClient
|
|||||||
# @option opts [Order] :body order placed for purchasing the pet
|
# @option opts [Order] :body order placed for purchasing the pet
|
||||||
# @return Order
|
# @return Order
|
||||||
def self.place_order(opts = {})
|
def self.place_order(opts = {})
|
||||||
# verify existence of params
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/store/order".sub('{format}','json')
|
path = "/store/order".sub('{format}','json')
|
||||||
@ -54,41 +57,24 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = Swagger::Request.object_to_http_body(opts[:'body'])
|
||||||
_body_param = opts[:'body']
|
|
||||||
if _body_param != nil
|
|
||||||
if _body_param.is_a?(Array)
|
|
||||||
_array = Array.new
|
|
||||||
_body_param.each do |item|
|
|
||||||
if item.respond_to?(:to_body)
|
|
||||||
_array.push item.to_body
|
|
||||||
else
|
|
||||||
_array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = _array
|
|
||||||
else
|
|
||||||
if _body_param.respond_to?(:to_body)
|
|
||||||
post_body = _body_param.to_body
|
|
||||||
else
|
|
||||||
post_body = _body_param
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:POST, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
response = Swagger::Request.new(:POST, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
Order.new(response)
|
obj = Order.new() and obj.build_from_hash(response)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Find purchase order by ID
|
# Find purchase order by ID
|
||||||
# For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
# For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
@ -96,8 +82,10 @@ module SwaggerClient
|
|||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return Order
|
# @return Order
|
||||||
def self.get_order_by_id(order_id, opts = {})
|
def self.get_order_by_id(order_id, opts = {})
|
||||||
# verify existence of params
|
|
||||||
raise "order_id is required" if order_id.nil?
|
# verify the required parameter 'order_id' is set
|
||||||
|
raise "Missing the required parameter 'order_id' when calling get_order_by_id" if order_id.nil?
|
||||||
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
|
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
|
||||||
@ -108,21 +96,24 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
Order.new(response)
|
obj = Order.new() and obj.build_from_hash(response)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Delete purchase order by ID
|
# Delete purchase order by ID
|
||||||
# For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
# For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
@ -130,8 +121,10 @@ module SwaggerClient
|
|||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return void
|
# @return void
|
||||||
def self.delete_order(order_id, opts = {})
|
def self.delete_order(order_id, opts = {})
|
||||||
# verify existence of params
|
|
||||||
raise "order_id is required" if order_id.nil?
|
# verify the required parameter 'order_id' is set
|
||||||
|
raise "Missing the required parameter 'order_id' when calling delete_order" if order_id.nil?
|
||||||
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
|
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
|
||||||
@ -142,19 +135,22 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
@ -11,7 +11,7 @@ module SwaggerClient
|
|||||||
# @option opts [User] :body Created user object
|
# @option opts [User] :body Created user object
|
||||||
# @return void
|
# @return void
|
||||||
def self.create_user(opts = {})
|
def self.create_user(opts = {})
|
||||||
# verify existence of params
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user".sub('{format}','json')
|
path = "/user".sub('{format}','json')
|
||||||
@ -22,40 +22,23 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = Swagger::Request.object_to_http_body(opts[:'body'])
|
||||||
_body_param = opts[:'body']
|
|
||||||
if _body_param != nil
|
|
||||||
if _body_param.is_a?(Array)
|
|
||||||
_array = Array.new
|
|
||||||
_body_param.each do |item|
|
|
||||||
if item.respond_to?(:to_body)
|
|
||||||
_array.push item.to_body
|
|
||||||
else
|
|
||||||
_array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = _array
|
|
||||||
else
|
|
||||||
if _body_param.respond_to?(:to_body)
|
|
||||||
post_body = _body_param.to_body
|
|
||||||
else
|
|
||||||
post_body = _body_param
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates list of users with given input array
|
# Creates list of users with given input array
|
||||||
#
|
#
|
||||||
@ -63,7 +46,7 @@ module SwaggerClient
|
|||||||
# @option opts [array[User]] :body List of user object
|
# @option opts [array[User]] :body List of user object
|
||||||
# @return void
|
# @return void
|
||||||
def self.create_users_with_array_input(opts = {})
|
def self.create_users_with_array_input(opts = {})
|
||||||
# verify existence of params
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user/createWithArray".sub('{format}','json')
|
path = "/user/createWithArray".sub('{format}','json')
|
||||||
@ -74,40 +57,23 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = Swagger::Request.object_to_http_body(opts[:'body'])
|
||||||
_body_param = opts[:'body']
|
|
||||||
if _body_param != nil
|
|
||||||
if _body_param.is_a?(Array)
|
|
||||||
_array = Array.new
|
|
||||||
_body_param.each do |item|
|
|
||||||
if item.respond_to?(:to_body)
|
|
||||||
_array.push item.to_body
|
|
||||||
else
|
|
||||||
_array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = _array
|
|
||||||
else
|
|
||||||
if _body_param.respond_to?(:to_body)
|
|
||||||
post_body = _body_param.to_body
|
|
||||||
else
|
|
||||||
post_body = _body_param
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates list of users with given input array
|
# Creates list of users with given input array
|
||||||
#
|
#
|
||||||
@ -115,7 +81,7 @@ module SwaggerClient
|
|||||||
# @option opts [array[User]] :body List of user object
|
# @option opts [array[User]] :body List of user object
|
||||||
# @return void
|
# @return void
|
||||||
def self.create_users_with_list_input(opts = {})
|
def self.create_users_with_list_input(opts = {})
|
||||||
# verify existence of params
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user/createWithList".sub('{format}','json')
|
path = "/user/createWithList".sub('{format}','json')
|
||||||
@ -126,40 +92,23 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = Swagger::Request.object_to_http_body(opts[:'body'])
|
||||||
_body_param = opts[:'body']
|
|
||||||
if _body_param != nil
|
|
||||||
if _body_param.is_a?(Array)
|
|
||||||
_array = Array.new
|
|
||||||
_body_param.each do |item|
|
|
||||||
if item.respond_to?(:to_body)
|
|
||||||
_array.push item.to_body
|
|
||||||
else
|
|
||||||
_array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = _array
|
|
||||||
else
|
|
||||||
if _body_param.respond_to?(:to_body)
|
|
||||||
post_body = _body_param.to_body
|
|
||||||
else
|
|
||||||
post_body = _body_param
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
end
|
end
|
||||||
|
|
||||||
# Logs user into the system
|
# Logs user into the system
|
||||||
#
|
#
|
||||||
@ -168,7 +117,7 @@ module SwaggerClient
|
|||||||
# @option opts [string] :password The password for login in clear text
|
# @option opts [string] :password The password for login in clear text
|
||||||
# @return string
|
# @return string
|
||||||
def self.login_user(opts = {})
|
def self.login_user(opts = {})
|
||||||
# verify existence of params
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user/login".sub('{format}','json')
|
path = "/user/login".sub('{format}','json')
|
||||||
@ -181,28 +130,31 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
string.new(response)
|
obj = string.new() and obj.build_from_hash(response)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Logs out current logged in user session
|
# Logs out current logged in user session
|
||||||
#
|
#
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return void
|
# @return void
|
||||||
def self.logout_user(opts = {})
|
def self.logout_user(opts = {})
|
||||||
# verify existence of params
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user/logout".sub('{format}','json')
|
path = "/user/logout".sub('{format}','json')
|
||||||
@ -213,20 +165,23 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:GET, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:GET, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get user by user name
|
# Get user by user name
|
||||||
#
|
#
|
||||||
@ -234,8 +189,10 @@ module SwaggerClient
|
|||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return User
|
# @return User
|
||||||
def self.get_user_by_name(username, opts = {})
|
def self.get_user_by_name(username, opts = {})
|
||||||
# verify existence of params
|
|
||||||
raise "username is required" if username.nil?
|
# verify the required parameter 'username' is set
|
||||||
|
raise "Missing the required parameter 'username' when calling get_user_by_name" if username.nil?
|
||||||
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
|
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
|
||||||
@ -246,21 +203,24 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
User.new(response)
|
obj = User.new() and obj.build_from_hash(response)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Updated user
|
# Updated user
|
||||||
# This can only be done by the logged in user.
|
# This can only be done by the logged in user.
|
||||||
@ -269,8 +229,10 @@ module SwaggerClient
|
|||||||
# @option opts [User] :body Updated user object
|
# @option opts [User] :body Updated user object
|
||||||
# @return void
|
# @return void
|
||||||
def self.update_user(username, opts = {})
|
def self.update_user(username, opts = {})
|
||||||
# verify existence of params
|
|
||||||
raise "username is required" if username.nil?
|
# verify the required parameter 'username' is set
|
||||||
|
raise "Missing the required parameter 'username' when calling update_user" if username.nil?
|
||||||
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
|
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
|
||||||
@ -281,40 +243,23 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = Swagger::Request.object_to_http_body(opts[:'body'])
|
||||||
_body_param = opts[:'body']
|
|
||||||
if _body_param != nil
|
|
||||||
if _body_param.is_a?(Array)
|
|
||||||
_array = Array.new
|
|
||||||
_body_param.each do |item|
|
|
||||||
if item.respond_to?(:to_body)
|
|
||||||
_array.push item.to_body
|
|
||||||
else
|
|
||||||
_array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = _array
|
|
||||||
else
|
|
||||||
if _body_param.respond_to?(:to_body)
|
|
||||||
post_body = _body_param.to_body
|
|
||||||
else
|
|
||||||
post_body = _body_param
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
end
|
end
|
||||||
|
|
||||||
# Delete user
|
# Delete user
|
||||||
# This can only be done by the logged in user.
|
# This can only be done by the logged in user.
|
||||||
@ -322,8 +267,10 @@ module SwaggerClient
|
|||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @return void
|
# @return void
|
||||||
def self.delete_user(username, opts = {})
|
def self.delete_user(username, opts = {})
|
||||||
# verify existence of params
|
|
||||||
raise "username is required" if username.nil?
|
# verify the required parameter 'username' is set
|
||||||
|
raise "Missing the required parameter 'username' when calling delete_user" if username.nil?
|
||||||
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
|
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
|
||||||
@ -334,19 +281,22 @@ module SwaggerClient
|
|||||||
# header parameters
|
# header parameters
|
||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
# HTTP header 'Accept' (if needed)
|
||||||
header_params['Accept'] = _header_accept if _header_accept != ''
|
_header_accept = ['application/json', 'application/xml']
|
||||||
|
_header_accept_result = Swagger::Request.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||||
|
|
||||||
|
# HTTP header 'Content-Type'
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = Swagger::Request.select_header_content_type(_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
@ -0,0 +1,83 @@
|
|||||||
|
module SwaggerClient
|
||||||
|
# base class containing fundamental method such as to_hash, build_from_hash and more
|
||||||
|
class BaseObject
|
||||||
|
|
||||||
|
# return the object in the form of hash
|
||||||
|
def to_body
|
||||||
|
body = {}
|
||||||
|
self.class.attribute_map.each_pair do |key, value|
|
||||||
|
body[value] = self.send(key) unless self.send(key).nil?
|
||||||
|
end
|
||||||
|
body
|
||||||
|
end
|
||||||
|
|
||||||
|
# build the object from hash
|
||||||
|
def build_from_hash(attributes)
|
||||||
|
return nil unless attributes.is_a?(Hash)
|
||||||
|
self.class.swagger_types.each_pair do |key, type|
|
||||||
|
if type =~ /^array\[(.*)\]/i
|
||||||
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||||
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
||||||
|
else
|
||||||
|
#TODO show warning in debug mode
|
||||||
|
end
|
||||||
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||||
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||||
|
else
|
||||||
|
# data not found in attributes(hash), not an issue as the data can be optional
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
|
def _deserialize(type, value)
|
||||||
|
case type.to_sym
|
||||||
|
when :DateTime
|
||||||
|
DateTime.parse(value)
|
||||||
|
when :string
|
||||||
|
value.to_s
|
||||||
|
when :int
|
||||||
|
value.to_i
|
||||||
|
when :double
|
||||||
|
value.to_f
|
||||||
|
when :boolean
|
||||||
|
if value =~ /^(true|t|yes|y|1)$/i
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
else # model
|
||||||
|
_model = SwaggerClient.const_get(type).new
|
||||||
|
_model.build_from_hash(value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# to_body is an alias to to_body (backward compatibility)
|
||||||
|
def to_hash
|
||||||
|
hash = {}
|
||||||
|
self.class.attribute_map.each_pair do |key, value|
|
||||||
|
if self.send(key).is_a?(Array)
|
||||||
|
next if self.send(key).empty?
|
||||||
|
hash[value] = self.send(key).select{|v| !v.nil?}.map{ |v| _to_hash v} unless self.send(key).nil?
|
||||||
|
else
|
||||||
|
unless (_tmp_value = _to_hash self.send(key)).nil?
|
||||||
|
hash[value] = _tmp_value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
hash
|
||||||
|
end
|
||||||
|
|
||||||
|
# Method to output non-array value in the form of hash
|
||||||
|
# For object, use to_hash. Otherwise, just return the value
|
||||||
|
def _to_hash(value)
|
||||||
|
if value.respond_to? :to_hash
|
||||||
|
value.to_hash
|
||||||
|
else
|
||||||
|
value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -1,35 +1,44 @@
|
|||||||
module SwaggerClient
|
module SwaggerClient
|
||||||
class Category
|
#
|
||||||
|
class Category < BaseObject
|
||||||
attr_accessor :id, :name
|
attr_accessor :id, :name
|
||||||
# :internal => :external
|
# attribute mapping from ruby-style variable name to JSON key
|
||||||
def self.attribute_map
|
def self.attribute_map
|
||||||
{
|
{
|
||||||
:id => :'id',
|
|
||||||
:name => :'name'
|
#
|
||||||
|
:'id' => :'id',
|
||||||
|
|
||||||
|
#
|
||||||
|
:'name' => :'name'
|
||||||
|
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
# attribute type
|
||||||
|
def self.swagger_types
|
||||||
|
{
|
||||||
|
:'id' => :'int',
|
||||||
|
:'name' => :'string'
|
||||||
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(attributes = {})
|
def initialize(attributes = {})
|
||||||
return if attributes.empty?
|
return if !attributes.is_a?(Hash) || attributes.empty?
|
||||||
# Morph attribute keys into undescored rubyish style
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"id"]
|
|
||||||
@id = attributes["id"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"name"]
|
|
||||||
@name = attributes["name"]
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_body
|
# convert string to symbol for hash key
|
||||||
body = {}
|
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
||||||
self.class.attribute_map.each_pair do |key, value|
|
|
||||||
body[value] = self.send(key) unless self.send(key).nil?
|
|
||||||
|
if attributes[:'id']
|
||||||
|
@id = attributes[:'id']
|
||||||
end
|
end
|
||||||
body
|
|
||||||
|
if attributes[:'name']
|
||||||
|
@name = attributes[:'name']
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,55 +1,76 @@
|
|||||||
module SwaggerClient
|
module SwaggerClient
|
||||||
class Order
|
#
|
||||||
|
class Order < BaseObject
|
||||||
attr_accessor :id, :pet_id, :quantity, :ship_date, :status, :complete
|
attr_accessor :id, :pet_id, :quantity, :ship_date, :status, :complete
|
||||||
# :internal => :external
|
# attribute mapping from ruby-style variable name to JSON key
|
||||||
def self.attribute_map
|
def self.attribute_map
|
||||||
{
|
{
|
||||||
:id => :'id',
|
|
||||||
:pet_id => :'petId',
|
#
|
||||||
:quantity => :'quantity',
|
:'id' => :'id',
|
||||||
:ship_date => :'shipDate',
|
|
||||||
:status => :'status',
|
#
|
||||||
:complete => :'complete'
|
:'pet_id' => :'petId',
|
||||||
|
|
||||||
|
#
|
||||||
|
:'quantity' => :'quantity',
|
||||||
|
|
||||||
|
#
|
||||||
|
:'ship_date' => :'shipDate',
|
||||||
|
|
||||||
|
# Order Status
|
||||||
|
:'status' => :'status',
|
||||||
|
|
||||||
|
#
|
||||||
|
:'complete' => :'complete'
|
||||||
|
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
# attribute type
|
||||||
|
def self.swagger_types
|
||||||
|
{
|
||||||
|
:'id' => :'int',
|
||||||
|
:'pet_id' => :'int',
|
||||||
|
:'quantity' => :'int',
|
||||||
|
:'ship_date' => :'DateTime',
|
||||||
|
:'status' => :'string',
|
||||||
|
:'complete' => :'boolean'
|
||||||
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(attributes = {})
|
def initialize(attributes = {})
|
||||||
return if attributes.empty?
|
return if !attributes.is_a?(Hash) || attributes.empty?
|
||||||
# Morph attribute keys into undescored rubyish style
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"id"]
|
|
||||||
@id = attributes["id"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"pet_id"]
|
|
||||||
@pet_id = attributes["petId"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"quantity"]
|
|
||||||
@quantity = attributes["quantity"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"ship_date"]
|
|
||||||
@ship_date = attributes["shipDate"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"status"]
|
|
||||||
@status = attributes["status"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"complete"]
|
|
||||||
@complete = attributes["complete"]
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_body
|
# convert string to symbol for hash key
|
||||||
body = {}
|
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
||||||
self.class.attribute_map.each_pair do |key, value|
|
|
||||||
body[value] = self.send(key) unless self.send(key).nil?
|
|
||||||
|
if attributes[:'id']
|
||||||
|
@id = attributes[:'id']
|
||||||
end
|
end
|
||||||
body
|
|
||||||
|
if attributes[:'petId']
|
||||||
|
@pet_id = attributes[:'petId']
|
||||||
|
end
|
||||||
|
|
||||||
|
if attributes[:'quantity']
|
||||||
|
@quantity = attributes[:'quantity']
|
||||||
|
end
|
||||||
|
|
||||||
|
if attributes[:'shipDate']
|
||||||
|
@ship_date = attributes[:'shipDate']
|
||||||
|
end
|
||||||
|
|
||||||
|
if attributes[:'status']
|
||||||
|
@status = attributes[:'status']
|
||||||
|
end
|
||||||
|
|
||||||
|
if attributes[:'complete']
|
||||||
|
@complete = attributes[:'complete']
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,59 +1,80 @@
|
|||||||
module SwaggerClient
|
module SwaggerClient
|
||||||
class Pet
|
#
|
||||||
|
class Pet < BaseObject
|
||||||
attr_accessor :id, :category, :name, :photo_urls, :tags, :status
|
attr_accessor :id, :category, :name, :photo_urls, :tags, :status
|
||||||
# :internal => :external
|
# attribute mapping from ruby-style variable name to JSON key
|
||||||
def self.attribute_map
|
def self.attribute_map
|
||||||
{
|
{
|
||||||
:id => :'id',
|
|
||||||
:category => :'category',
|
#
|
||||||
:name => :'name',
|
:'id' => :'id',
|
||||||
:photo_urls => :'photoUrls',
|
|
||||||
:tags => :'tags',
|
#
|
||||||
:status => :'status'
|
:'category' => :'category',
|
||||||
|
|
||||||
|
#
|
||||||
|
:'name' => :'name',
|
||||||
|
|
||||||
|
#
|
||||||
|
:'photo_urls' => :'photoUrls',
|
||||||
|
|
||||||
|
#
|
||||||
|
:'tags' => :'tags',
|
||||||
|
|
||||||
|
# pet status in the store
|
||||||
|
:'status' => :'status'
|
||||||
|
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
# attribute type
|
||||||
|
def self.swagger_types
|
||||||
|
{
|
||||||
|
:'id' => :'int',
|
||||||
|
:'category' => :'Category',
|
||||||
|
:'name' => :'string',
|
||||||
|
:'photo_urls' => :'array[string]',
|
||||||
|
:'tags' => :'array[Tag]',
|
||||||
|
:'status' => :'string'
|
||||||
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(attributes = {})
|
def initialize(attributes = {})
|
||||||
return if attributes.empty?
|
return if !attributes.is_a?(Hash) || attributes.empty?
|
||||||
# Morph attribute keys into undescored rubyish style
|
|
||||||
|
# convert string to symbol for hash key
|
||||||
|
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
||||||
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"id"]
|
if attributes[:'id']
|
||||||
@id = attributes["id"]
|
@id = attributes[:'id']
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"category"]
|
if attributes[:'category']
|
||||||
@category = attributes["category"]
|
@category = attributes[:'category']
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"name"]
|
if attributes[:'name']
|
||||||
@name = attributes["name"]
|
@name = attributes[:'name']
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"photo_urls"]
|
if attributes[:'photoUrls']
|
||||||
if (value = attributes["photoUrls"]).is_a?(Array)
|
if (value = attributes[:'photoUrls']).is_a?(Array)
|
||||||
@photo_urls = value
|
@photo_urls = value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"tags"]
|
if attributes[:'tags']
|
||||||
if (value = attributes["tags"]).is_a?(Array)
|
if (value = attributes[:'tags']).is_a?(Array)
|
||||||
@tags = value.map{ |v| Tag.new(v) }
|
@tags = value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"status"]
|
if attributes[:'status']
|
||||||
@status = attributes["status"]
|
@status = attributes[:'status']
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_body
|
|
||||||
body = {}
|
|
||||||
self.class.attribute_map.each_pair do |key, value|
|
|
||||||
body[value] = self.send(key) unless self.send(key).nil?
|
|
||||||
end
|
|
||||||
body
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,35 +1,44 @@
|
|||||||
module SwaggerClient
|
module SwaggerClient
|
||||||
class Tag
|
#
|
||||||
|
class Tag < BaseObject
|
||||||
attr_accessor :id, :name
|
attr_accessor :id, :name
|
||||||
# :internal => :external
|
# attribute mapping from ruby-style variable name to JSON key
|
||||||
def self.attribute_map
|
def self.attribute_map
|
||||||
{
|
{
|
||||||
:id => :'id',
|
|
||||||
:name => :'name'
|
#
|
||||||
|
:'id' => :'id',
|
||||||
|
|
||||||
|
#
|
||||||
|
:'name' => :'name'
|
||||||
|
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
# attribute type
|
||||||
|
def self.swagger_types
|
||||||
|
{
|
||||||
|
:'id' => :'int',
|
||||||
|
:'name' => :'string'
|
||||||
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(attributes = {})
|
def initialize(attributes = {})
|
||||||
return if attributes.empty?
|
return if !attributes.is_a?(Hash) || attributes.empty?
|
||||||
# Morph attribute keys into undescored rubyish style
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"id"]
|
|
||||||
@id = attributes["id"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"name"]
|
|
||||||
@name = attributes["name"]
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_body
|
# convert string to symbol for hash key
|
||||||
body = {}
|
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
||||||
self.class.attribute_map.each_pair do |key, value|
|
|
||||||
body[value] = self.send(key) unless self.send(key).nil?
|
|
||||||
|
if attributes[:'id']
|
||||||
|
@id = attributes[:'id']
|
||||||
end
|
end
|
||||||
body
|
|
||||||
|
if attributes[:'name']
|
||||||
|
@name = attributes[:'name']
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,65 +1,92 @@
|
|||||||
module SwaggerClient
|
module SwaggerClient
|
||||||
class User
|
#
|
||||||
|
class User < BaseObject
|
||||||
attr_accessor :id, :username, :first_name, :last_name, :email, :password, :phone, :user_status
|
attr_accessor :id, :username, :first_name, :last_name, :email, :password, :phone, :user_status
|
||||||
# :internal => :external
|
# attribute mapping from ruby-style variable name to JSON key
|
||||||
def self.attribute_map
|
def self.attribute_map
|
||||||
{
|
{
|
||||||
:id => :'id',
|
|
||||||
:username => :'username',
|
#
|
||||||
:first_name => :'firstName',
|
:'id' => :'id',
|
||||||
:last_name => :'lastName',
|
|
||||||
:email => :'email',
|
#
|
||||||
:password => :'password',
|
:'username' => :'username',
|
||||||
:phone => :'phone',
|
|
||||||
:user_status => :'userStatus'
|
#
|
||||||
|
:'first_name' => :'firstName',
|
||||||
|
|
||||||
|
#
|
||||||
|
:'last_name' => :'lastName',
|
||||||
|
|
||||||
|
#
|
||||||
|
:'email' => :'email',
|
||||||
|
|
||||||
|
#
|
||||||
|
:'password' => :'password',
|
||||||
|
|
||||||
|
#
|
||||||
|
:'phone' => :'phone',
|
||||||
|
|
||||||
|
# User Status
|
||||||
|
:'user_status' => :'userStatus'
|
||||||
|
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
# attribute type
|
||||||
|
def self.swagger_types
|
||||||
|
{
|
||||||
|
:'id' => :'int',
|
||||||
|
:'username' => :'string',
|
||||||
|
:'first_name' => :'string',
|
||||||
|
:'last_name' => :'string',
|
||||||
|
:'email' => :'string',
|
||||||
|
:'password' => :'string',
|
||||||
|
:'phone' => :'string',
|
||||||
|
:'user_status' => :'int'
|
||||||
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(attributes = {})
|
def initialize(attributes = {})
|
||||||
return if attributes.empty?
|
return if !attributes.is_a?(Hash) || attributes.empty?
|
||||||
# Morph attribute keys into undescored rubyish style
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"id"]
|
|
||||||
@id = attributes["id"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"username"]
|
|
||||||
@username = attributes["username"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"first_name"]
|
|
||||||
@first_name = attributes["firstName"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"last_name"]
|
|
||||||
@last_name = attributes["lastName"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"email"]
|
|
||||||
@email = attributes["email"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"password"]
|
|
||||||
@password = attributes["password"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"phone"]
|
|
||||||
@phone = attributes["phone"]
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.class.attribute_map[:"user_status"]
|
|
||||||
@user_status = attributes["userStatus"]
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_body
|
# convert string to symbol for hash key
|
||||||
body = {}
|
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
||||||
self.class.attribute_map.each_pair do |key, value|
|
|
||||||
body[value] = self.send(key) unless self.send(key).nil?
|
|
||||||
|
if attributes[:'id']
|
||||||
|
@id = attributes[:'id']
|
||||||
end
|
end
|
||||||
body
|
|
||||||
|
if attributes[:'username']
|
||||||
|
@username = attributes[:'username']
|
||||||
|
end
|
||||||
|
|
||||||
|
if attributes[:'firstName']
|
||||||
|
@first_name = attributes[:'firstName']
|
||||||
|
end
|
||||||
|
|
||||||
|
if attributes[:'lastName']
|
||||||
|
@last_name = attributes[:'lastName']
|
||||||
|
end
|
||||||
|
|
||||||
|
if attributes[:'email']
|
||||||
|
@email = attributes[:'email']
|
||||||
|
end
|
||||||
|
|
||||||
|
if attributes[:'password']
|
||||||
|
@password = attributes[:'password']
|
||||||
|
end
|
||||||
|
|
||||||
|
if attributes[:'phone']
|
||||||
|
@phone = attributes[:'phone']
|
||||||
|
end
|
||||||
|
|
||||||
|
if attributes[:'userStatus']
|
||||||
|
@user_status = attributes[:'userStatus']
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
require 'logger'
|
require 'logger'
|
||||||
|
require 'json'
|
||||||
|
|
||||||
module SwaggerClient
|
module SwaggerClient
|
||||||
module Swagger
|
module Swagger
|
||||||
class << self
|
class << self
|
||||||
attr_accessor :logger
|
attr_accessor :logger
|
||||||
|
|
||||||
# A Swagger configuration object. Must act like a hash and return sensible
|
# A Swagger configuration object. Must act like a hash and return sensible
|
||||||
# values for all Swagger configuration options. See Swagger::Configuration.
|
# values for all Swagger configuration options. See Swagger::Configuration.
|
||||||
attr_accessor :configuration
|
attr_accessor :configuration
|
||||||
|
|
||||||
attr_accessor :resources
|
attr_accessor :resources
|
||||||
|
|
||||||
# Call this method to modify defaults in your initializers.
|
# Call this method to modify defaults in your initializers.
|
||||||
#
|
#
|
||||||
# @example
|
# @example
|
||||||
@ -38,31 +39,31 @@ module SwaggerClient
|
|||||||
configuration.base_path = "/#{configuration.base_path}".gsub(/\/+/, '/')
|
configuration.base_path = "/#{configuration.base_path}".gsub(/\/+/, '/')
|
||||||
configuration.base_path = "" if configuration.base_path == "/"
|
configuration.base_path = "" if configuration.base_path == "/"
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticated?
|
def authenticated?
|
||||||
Swagger.configuration.auth_token.present?
|
Swagger.configuration.auth_token.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def de_authenticate
|
def de_authenticate
|
||||||
Swagger.configuration.auth_token = nil
|
Swagger.configuration.auth_token = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate
|
def authenticate
|
||||||
return if Swagger.authenticated?
|
return if Swagger.authenticated?
|
||||||
|
|
||||||
if Swagger.configuration.username.blank? || Swagger.configuration.password.blank?
|
if Swagger.configuration.username.blank? || Swagger.configuration.password.blank?
|
||||||
raise ClientError, "Username and password are required to authenticate."
|
raise ClientError, "Username and password are required to authenticate."
|
||||||
end
|
end
|
||||||
|
|
||||||
request = Swagger::Request.new(
|
request = Swagger::Request.new(
|
||||||
:get,
|
:get,
|
||||||
"account/authenticate/{username}",
|
"account/authenticate/{username}",
|
||||||
:params => {
|
:params => {
|
||||||
:username => Swagger.configuration.username,
|
:username => Swagger.configuration.username,
|
||||||
:password => Swagger.configuration.password
|
:password => Swagger.configuration.password
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
response_body = request.response.body
|
response_body = request.response.body
|
||||||
Swagger.configuration.auth_token = response_body['token']
|
Swagger.configuration.auth_token = response_body['token']
|
||||||
end
|
end
|
||||||
@ -74,4 +75,4 @@ module SwaggerClient
|
|||||||
|
|
||||||
class ClientError < StandardError
|
class ClientError < StandardError
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -24,21 +24,21 @@ module SwaggerClient
|
|||||||
if attributes[:headers].present? && attributes[:headers].has_key?(:api_key)
|
if attributes[:headers].present? && attributes[:headers].has_key?(:api_key)
|
||||||
default_headers.delete(:api_key)
|
default_headers.delete(:api_key)
|
||||||
end
|
end
|
||||||
|
|
||||||
# api_key from params hash trumps all others (headers and default_headers)
|
# api_key from params hash trumps all others (headers and default_headers)
|
||||||
if attributes[:params].present? && attributes[:params].has_key?(:api_key)
|
if attributes[:params].present? && attributes[:params].has_key?(:api_key)
|
||||||
default_headers.delete(:api_key)
|
default_headers.delete(:api_key)
|
||||||
attributes[:headers].delete(:api_key) if attributes[:headers].present?
|
attributes[:headers].delete(:api_key) if attributes[:headers].present?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Merge argument headers into defaults
|
# Merge argument headers into defaults
|
||||||
attributes[:headers] = default_headers.merge(attributes[:headers] || {})
|
attributes[:headers] = default_headers.merge(attributes[:headers] || {})
|
||||||
|
|
||||||
# Stick in the auth token if there is one
|
# Stick in the auth token if there is one
|
||||||
if Swagger.authenticated?
|
if Swagger.authenticated?
|
||||||
attributes[:headers].merge!({:auth_token => Swagger.configuration.auth_token})
|
attributes[:headers].merge!({:auth_token => Swagger.configuration.auth_token})
|
||||||
end
|
end
|
||||||
|
|
||||||
self.http_method = http_method.to_sym
|
self.http_method = http_method.to_sym
|
||||||
self.path = path
|
self.path = path
|
||||||
attributes.each do |name, value|
|
attributes.each do |name, value|
|
||||||
@ -47,20 +47,20 @@ module SwaggerClient
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Construct a base URL
|
# Construct a base URL
|
||||||
def url(options = {})
|
def url(options = {})
|
||||||
u = Addressable::URI.new(
|
u = Addressable::URI.new(
|
||||||
:scheme => Swagger.configuration.scheme,
|
:scheme => Swagger.configuration.scheme,
|
||||||
:host => Swagger.configuration.host,
|
:host => Swagger.configuration.host,
|
||||||
:path => self.interpreted_path,
|
:path => self.interpreted_path,
|
||||||
:query => self.query_string.sub(/\?/, '')
|
:query => self.query_string.sub(/\?/, '')
|
||||||
).to_s
|
).to_s
|
||||||
|
|
||||||
# Drop trailing question mark, if present
|
# Drop trailing question mark, if present
|
||||||
u.sub! /\?$/, ''
|
u.sub! /\?$/, ''
|
||||||
|
|
||||||
# Obfuscate API key?
|
# Obfuscate API key?
|
||||||
u.sub! /api\_key=\w+/, 'api_key=YOUR_API_KEY' if options[:obfuscated]
|
u.sub! /api\_key=\w+/, 'api_key=YOUR_API_KEY' if options[:obfuscated]
|
||||||
|
|
||||||
u
|
u
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -83,18 +83,18 @@ module SwaggerClient
|
|||||||
# e.g. /words/blah => /words/blah.{format}
|
# e.g. /words/blah => /words/blah.{format}
|
||||||
if Swagger.configuration.force_ending_format
|
if Swagger.configuration.force_ending_format
|
||||||
unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s }
|
unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s }
|
||||||
p = "#{p}.#{format}"
|
p = "#{p}.#{format}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
p = p.sub("{format}", self.format.to_s)
|
p = p.sub("{format}", self.format.to_s)
|
||||||
|
|
||||||
URI.encode [Swagger.configuration.base_path, p].join("/").gsub(/\/+/, '/')
|
URI.encode [Swagger.configuration.base_path, p].join("/").gsub(/\/+/, '/')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Massage the request body into a state of readiness
|
# Massage the request body into a state of readiness
|
||||||
# If body is a hash, camelize all keys then convert to a json string
|
# If body is a hash, camelize all keys then convert to a json string
|
||||||
def body=(value)
|
def body=(value)
|
||||||
if value.is_a?(Hash)
|
if value.is_a?(Hash)
|
||||||
value = value.inject({}) do |memo, (k,v)|
|
value = value.inject({}) do |memo, (k,v)|
|
||||||
memo[k.to_s.camelize(:lower).to_sym] = v
|
memo[k.to_s.camelize(:lower).to_sym] = v
|
||||||
@ -103,9 +103,9 @@ module SwaggerClient
|
|||||||
end
|
end
|
||||||
@body = value
|
@body = value
|
||||||
end
|
end
|
||||||
|
|
||||||
# If body is an object, JSONify it before making the actual request.
|
# If body is an object, JSONify it before making the actual request.
|
||||||
# For form parameters, remove empty value
|
# For form parameters, remove empty value
|
||||||
def outgoing_body
|
def outgoing_body
|
||||||
# http form
|
# http form
|
||||||
if @body.nil? && @form_params && !@form_params.empty?
|
if @body.nil? && @form_params && !@form_params.empty?
|
||||||
@ -118,7 +118,7 @@ module SwaggerClient
|
|||||||
@body.is_a?(String) ? @body : @body.to_json
|
@body.is_a?(String) ? @body : @body.to_json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Construct a query string from the query-string-type params
|
# Construct a query string from the query-string-type params
|
||||||
def query_string
|
def query_string
|
||||||
# Iterate over all params,
|
# Iterate over all params,
|
||||||
@ -133,17 +133,17 @@ module SwaggerClient
|
|||||||
end
|
end
|
||||||
query_values[key] = value.to_s
|
query_values[key] = value.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
# We don't want to end up with '?' as our query string
|
# We don't want to end up with '?' as our query string
|
||||||
# if there aren't really any params
|
# if there aren't really any params
|
||||||
return "" if query_values.blank?
|
return "" if query_values.blank?
|
||||||
|
|
||||||
# Addressable requires query_values to be set after initialization..
|
# Addressable requires query_values to be set after initialization..
|
||||||
qs = Addressable::URI.new
|
qs = Addressable::URI.new
|
||||||
qs.query_values = query_values
|
qs.query_values = query_values
|
||||||
qs.to_s
|
qs.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def make
|
def make
|
||||||
#TODO use configuration setting to determine if debugging
|
#TODO use configuration setting to determine if debugging
|
||||||
#logger = Logger.new STDOUT
|
#logger = Logger.new STDOUT
|
||||||
@ -175,7 +175,7 @@ module SwaggerClient
|
|||||||
:body => self.outgoing_body,
|
:body => self.outgoing_body,
|
||||||
:headers => self.headers.stringify_keys,
|
:headers => self.headers.stringify_keys,
|
||||||
)
|
)
|
||||||
|
|
||||||
when :delete,:DELETE
|
when :delete,:DELETE
|
||||||
Typhoeus::Request.delete(
|
Typhoeus::Request.delete(
|
||||||
self.url,
|
self.url,
|
||||||
@ -185,21 +185,73 @@ module SwaggerClient
|
|||||||
end
|
end
|
||||||
Response.new(response)
|
Response.new(response)
|
||||||
end
|
end
|
||||||
|
|
||||||
def response
|
def response
|
||||||
self.make
|
self.make
|
||||||
end
|
end
|
||||||
|
|
||||||
def response_code_pretty
|
def response_code_pretty
|
||||||
return unless @response.present?
|
return unless @response.present?
|
||||||
@response.code.to_s
|
@response.code.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def response_headers_pretty
|
def response_headers_pretty
|
||||||
return unless @response.present?
|
return unless @response.present?
|
||||||
# JSON.pretty_generate(@response.headers).gsub(/\n/, '<br/>') # <- This was for RestClient
|
# JSON.pretty_generate(@response.headers).gsub(/\n/, '<br/>') # <- This was for RestClient
|
||||||
@response.headers.gsub(/\n/, '<br/>') # <- This is for Typhoeus
|
@response.headers.gsub(/\n/, '<br/>') # <- This is for Typhoeus
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# return 'Accept' based on an array of accept provided
|
||||||
|
# @param [Array] header_accept_array Array fo 'Accept'
|
||||||
|
# @return String Accept (e.g. application/json)
|
||||||
|
def self.select_header_accept header_accept_array
|
||||||
|
if header_accept_array.empty?
|
||||||
|
return
|
||||||
|
elsif header_accept_array.any?{ |s| s.casecmp('application/json')==0 }
|
||||||
|
'application/json' # look for json data by default
|
||||||
|
else
|
||||||
|
header_accept_array.join(',')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# return the content type based on an array of content-type provided
|
||||||
|
# @param [Array] content_type_array Array fo content-type
|
||||||
|
# @return String Content-Type (e.g. application/json)
|
||||||
|
def self.select_header_content_type content_type_array
|
||||||
|
if content_type_array.empty?
|
||||||
|
'application/json' # use application/json by default
|
||||||
|
elsif content_type_array.any?{ |s| s.casecmp('application/json')==0 }
|
||||||
|
'application/json' # use application/json if it's included
|
||||||
|
else
|
||||||
|
content_type_array[0]; # otherwise, use the first one
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# static method to convert object (array, hash, object, etc) to JSON string
|
||||||
|
# @param model object to be converted into JSON string
|
||||||
|
# @return string JSON string representation of the object
|
||||||
|
def self.object_to_http_body model
|
||||||
|
return if model.nil?
|
||||||
|
_body = nil
|
||||||
|
if model.is_a?(Array)
|
||||||
|
_body = model.map{|m| object_to_hash(m) }
|
||||||
|
else
|
||||||
|
_body = object_to_hash(model)
|
||||||
|
end
|
||||||
|
_body.to_json
|
||||||
|
end
|
||||||
|
|
||||||
|
# static method to convert object(non-array) to hash
|
||||||
|
# @param obj object to be converted into JSON string
|
||||||
|
# @return string JSON string representation of the object
|
||||||
|
def self.object_to_hash obj
|
||||||
|
if obj.respond_to?(:to_hash)
|
||||||
|
obj.to_hash
|
||||||
|
else
|
||||||
|
obj
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@ module SwaggerClient
|
|||||||
def code
|
def code
|
||||||
raw.code
|
raw.code
|
||||||
end
|
end
|
||||||
|
|
||||||
# Account for error messages that take different forms...
|
# Account for error messages that take different forms...
|
||||||
def error_message
|
def error_message
|
||||||
body['message']
|
body['message']
|
||||||
@ -28,12 +28,12 @@ module SwaggerClient
|
|||||||
# If body is JSON, parse it
|
# If body is JSON, parse it
|
||||||
# Otherwise return raw string
|
# Otherwise return raw string
|
||||||
def body
|
def body
|
||||||
JSON.parse raw.body
|
JSON.parse(raw.body, :symbolize_names => true)
|
||||||
rescue
|
rescue
|
||||||
raw.body
|
raw.body
|
||||||
end
|
end
|
||||||
|
|
||||||
# `headers_hash` is a Typhoeus-specific extension of Hash,
|
# `headers_hash` is a Typhoeus-specific extension of Hash,
|
||||||
# so simplify it back into a regular old Hash.
|
# so simplify it back into a regular old Hash.
|
||||||
def headers
|
def headers
|
||||||
h = {}
|
h = {}
|
||||||
@ -67,4 +67,4 @@ module SwaggerClient
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user