update ruby sample

This commit is contained in:
wing328 2016-04-09 17:55:52 +08:00
parent dd8b581827
commit e3c73f5819
23 changed files with 155 additions and 253 deletions

View File

@ -6,9 +6,9 @@ This is a sample server Petstore server. You can find out more about Swagger at
This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API verion: 1.0.0
- API version: 1.0.0
- Package version: 1.0.0
- Build date: 2016-03-29T21:03:44.069+08:00
- Build date: 2016-04-09T17:50:53.781+08:00
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
## Installation
@ -82,20 +82,20 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
*Petstore::PetApi* | [**add_pet_using_byte_array**](docs/PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store
*Petstore::PetApi* | [**add_pet_using_byte_array**](docs/PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store
*Petstore::PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
*Petstore::PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
*Petstore::PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags
*Petstore::PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID
*Petstore::PetApi* | [**get_pet_by_id_in_object**](docs/PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID'
*Petstore::PetApi* | [**pet_pet_idtesting_byte_arraytrue_get**](docs/PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID'
*Petstore::PetApi* | [**get_pet_by_id_in_object**](docs/PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID'
*Petstore::PetApi* | [**pet_pet_idtesting_byte_arraytrue_get**](docs/PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID'
*Petstore::PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet
*Petstore::PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data
*Petstore::PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image
*Petstore::StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
*Petstore::StoreApi* | [**find_orders_by_status**](docs/StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status
*Petstore::StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status
*Petstore::StoreApi* | [**get_inventory_in_object**](docs/StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory'
*Petstore::StoreApi* | [**get_inventory_in_object**](docs/StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory'
*Petstore::StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID
*Petstore::StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet
*Petstore::UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user

View File

@ -5,13 +5,13 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
[**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store
[**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store
[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags
[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID
[**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID'
[**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID'
[**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID'
[**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID'
[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet
[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data
[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image

View File

@ -7,7 +7,7 @@ Method | HTTP request | Description
[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
[**find_orders_by_status**](StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status
[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status
[**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory'
[**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory'
[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID
[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet

View File

@ -221,7 +221,7 @@ require 'petstore'
api_instance = Petstore::UserApi.new
username = "username_example" # String | The name that needs to be fetched. Use user1 for testing.
username = "username_example" # String | The name that needs to be fetched. Use user1 for testing.
begin
@ -237,7 +237,7 @@ end
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
### Return type

View File

@ -66,7 +66,6 @@ module Petstore
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
@ -101,7 +100,7 @@ module Petstore
end
# resource path
local_var_path = "/pet?testing_byte_array=true".sub('{format}','json')
local_var_path = "/pet?testing_byte_array=true".sub('{format}','json')
# query parameters
query_params = {}
@ -122,7 +121,6 @@ module Petstore
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
@ -184,8 +182,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -241,8 +238,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -299,8 +295,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -359,8 +354,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['api_key', 'petstore_auth']
auth_names = ['api_key', 'petstore_auth']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -398,7 +392,7 @@ module Petstore
fail "Missing the required parameter 'pet_id' when calling get_pet_by_id_in_object" if pet_id.nil?
# resource path
local_var_path = "/pet/{petId}?response=inline_arbitrary_object".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = "/pet/{petId}?response=inline_arbitrary_object".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
@ -419,8 +413,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['api_key', 'petstore_auth']
auth_names = ['api_key', 'petstore_auth']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -458,7 +451,7 @@ module Petstore
fail "Missing the required parameter 'pet_id' when calling pet_pet_idtesting_byte_arraytrue_get" if pet_id.nil?
# resource path
local_var_path = "/pet/{petId}?testing_byte_array=true".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = "/pet/{petId}?testing_byte_array=true".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
@ -479,8 +472,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['api_key', 'petstore_auth']
auth_names = ['api_key', 'petstore_auth']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -536,7 +528,6 @@ module Petstore
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
:header_params => header_params,
@ -601,8 +592,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -666,8 +656,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,

View File

@ -69,8 +69,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = []
auth_names = []
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -130,8 +129,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['test_api_client_id', 'test_api_client_secret']
auth_names = ['test_api_client_id', 'test_api_client_secret']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -185,8 +183,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['api_key']
auth_names = ['api_key']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -219,7 +216,7 @@ module Petstore
end
# resource path
local_var_path = "/store/inventory?response=arbitrary_object".sub('{format}','json')
local_var_path = "/store/inventory?response=arbitrary_object".sub('{format}','json')
# query parameters
query_params = {}
@ -240,8 +237,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['api_key']
auth_names = ['api_key']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -266,7 +262,7 @@ module Petstore
end
# 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
# @param order_id ID of pet that needs to be fetched
# @param [Hash] opts the optional parameters
# @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers
@ -300,8 +296,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['test_api_key_header', 'test_api_key_query']
auth_names = ['test_api_key_header', 'test_api_key_query']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -357,7 +352,6 @@ module Petstore
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['test_api_client_id', 'test_api_client_secret']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,

View File

@ -66,7 +66,6 @@ module Petstore
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = []
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
@ -122,7 +121,6 @@ module Petstore
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = []
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
@ -178,7 +176,6 @@ module Petstore
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = []
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
@ -237,8 +234,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['test_http_basic']
auth_names = ['test_http_basic']
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -253,7 +249,7 @@ module Petstore
# Get user by user name
#
# @param username The name that needs to be fetched. Use user1 for testing.
# @param username The name that needs to be fetched. Use user1 for testing.
# @param [Hash] opts the optional parameters
# @return [User]
def get_user_by_name(username, opts = {})
@ -263,7 +259,7 @@ module Petstore
# Get user by user name
#
# @param username The name that needs to be fetched. Use user1 for testing.
# @param username The name that needs to be fetched. Use user1 for testing.
# @param [Hash] opts the optional parameters
# @return [Array<(User, Fixnum, Hash)>] User data, response status code and response headers
def get_user_by_name_with_http_info(username, opts = {})
@ -296,8 +292,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = []
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -357,8 +352,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = []
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -412,8 +406,7 @@ module Petstore
# http body (model)
post_body = nil
auth_names = []
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
@ -473,7 +466,6 @@ module Petstore
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = []
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
:header_params => header_params,

View File

@ -90,9 +90,7 @@ module Petstore
query_params = opts[:query_params] || {}
form_params = opts[:form_params] || {}
update_params_for_auth! header_params, query_params, opts[:auth_names]
req_opts = {
:method => http_method,

View File

@ -23,9 +23,7 @@ module Petstore
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'class_name' => :'className'
}
end
@ -33,24 +31,24 @@ module Petstore
def self.swagger_types
{
:'class_name' => :'String'
}
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
# convert string to symbol for hash key
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes[:'className']
self.class_name = attributes[:'className']
end
end
# Check equality by comparing each attribute.
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
@ -58,35 +56,41 @@ module Petstore
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculate hash code according to all attributes.
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
def hash
[class_name].hash
end
# build the object from hash
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
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
# check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not
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 # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
@ -120,21 +124,25 @@ module Petstore
end
end
else # model
_model = Petstore.const_get(type).new
_model.build_from_hash(value)
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_body (backward compatibility))
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# return the object in the form of hash
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
@ -145,8 +153,10 @@ module Petstore
hash
end
# Method to output non-array value in the form of hash
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) }

View File

@ -25,11 +25,8 @@ module Petstore
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'class_name' => :'className',
:'declawed' => :'declawed'
}
end
@ -37,29 +34,28 @@ module Petstore
def self.swagger_types
{
:'class_name' => :'String',
:'declawed' => :'BOOLEAN'
:'declawed' => :'BOOLEAN'
}
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
# convert string to symbol for hash key
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes[:'className']
self.class_name = attributes[:'className']
end
if attributes[:'declawed']
self.declawed = attributes[:'declawed']
end
end
# Check equality by comparing each attribute.
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
@ -68,35 +64,41 @@ module Petstore
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculate hash code according to all attributes.
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
def hash
[class_name, declawed].hash
end
# build the object from hash
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
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
# check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not
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 # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
@ -130,21 +132,25 @@ module Petstore
end
end
else # model
_model = Petstore.const_get(type).new
_model.build_from_hash(value)
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_body (backward compatibility))
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# return the object in the form of hash
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
@ -155,8 +161,10 @@ module Petstore
hash
end
# Method to output non-array value in the form of hash
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) }

View File

@ -25,11 +25,8 @@ module Petstore
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'id' => :'id',
:'name' => :'name'
}
end
@ -37,8 +34,7 @@ module Petstore
def self.swagger_types
{
:'id' => :'Integer',
:'name' => :'String'
:'name' => :'String'
}
end
@ -50,15 +46,12 @@ module Petstore
# convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes[:'id']
self.id = attributes[:'id']
end
if attributes[:'name']
self.name = attributes[:'name']
end
end
# Checks equality by comparing each attribute.

View File

@ -25,11 +25,8 @@ module Petstore
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'class_name' => :'className',
:'breed' => :'breed'
}
end
@ -37,29 +34,28 @@ module Petstore
def self.swagger_types
{
:'class_name' => :'String',
:'breed' => :'String'
:'breed' => :'String'
}
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
# convert string to symbol for hash key
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes[:'className']
self.class_name = attributes[:'className']
end
if attributes[:'breed']
self.breed = attributes[:'breed']
end
end
# Check equality by comparing each attribute.
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
@ -68,35 +64,41 @@ module Petstore
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculate hash code according to all attributes.
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
def hash
[class_name, breed].hash
end
# build the object from hash
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
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
# check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not
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 # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
@ -130,21 +132,25 @@ module Petstore
end
end
else # model
_model = Petstore.const_get(type).new
_model.build_from_hash(value)
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_body (backward compatibility))
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# return the object in the form of hash
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
@ -155,8 +161,10 @@ module Petstore
hash
end
# Method to output non-array value in the form of hash
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) }

View File

@ -34,19 +34,12 @@ module Petstore
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'tags' => :'tags',
:'id' => :'id',
:'category' => :'category',
:'status' => :'status',
:'name' => :'name',
:'photo_urls' => :'photoUrls'
}
end
@ -54,12 +47,11 @@ module Petstore
def self.swagger_types
{
:'tags' => :'Array<Tag>',
:'id' => :'Integer',
:'category' => :'Object',
:'status' => :'String',
:'name' => :'String',
:'photo_urls' => :'Array<String>'
:'id' => :'Integer',
:'category' => :'Object',
:'status' => :'String',
:'name' => :'String',
:'photo_urls' => :'Array<String>'
}
end
@ -71,35 +63,28 @@ module Petstore
# convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes[:'tags']
if (value = attributes[:'tags']).is_a?(Array)
self.tags = value
end
end
if attributes[:'id']
self.id = attributes[:'id']
end
if attributes[:'category']
self.category = attributes[:'category']
end
if attributes[:'status']
self.status = attributes[:'status']
end
if attributes[:'name']
self.name = attributes[:'name']
end
if attributes[:'photoUrls']
if (value = attributes[:'photoUrls']).is_a?(Array)
self.photo_urls = value
end
end
end
# Custom attribute writer method checking allowed values (enum).

View File

@ -17,15 +17,14 @@ Terms of Service: http://swagger.io/terms/
require 'date'
module Petstore
# Model for testing model name starting with number
class Model200Response
attr_accessor :name
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'name' => :'name'
}
end
@ -33,7 +32,6 @@ module Petstore
def self.swagger_types
{
:'name' => :'Integer'
}
end
@ -45,11 +43,9 @@ module Petstore
# convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes[:'name']
self.name = attributes[:'name']
end
end
# Checks equality by comparing each attribute.

View File

@ -17,15 +17,14 @@ Terms of Service: http://swagger.io/terms/
require 'date'
module Petstore
# Model for testing reserved words
class ModelReturn
attr_accessor :_return
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'_return' => :'return'
}
end
@ -33,7 +32,6 @@ module Petstore
def self.swagger_types
{
:'_return' => :'Integer'
}
end
@ -45,11 +43,9 @@ module Petstore
# convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes[:'return']
self._return = attributes[:'return']
end
end
# Checks equality by comparing each attribute.

View File

@ -17,6 +17,7 @@ Terms of Service: http://swagger.io/terms/
require 'date'
module Petstore
# Model for testing model name same as property name
class Name
attr_accessor :name
@ -25,11 +26,8 @@ module Petstore
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'name' => :'name',
:'snake_case' => :'snake_case'
}
end
@ -37,8 +35,7 @@ module Petstore
def self.swagger_types
{
:'name' => :'Integer',
:'snake_case' => :'Integer'
:'snake_case' => :'Integer'
}
end
@ -50,15 +47,12 @@ module Petstore
# convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes[:'name']
self.name = attributes[:'name']
end
if attributes[:'snake_case']
self.snake_case = attributes[:'snake_case']
end
end
# Checks equality by comparing each attribute.

View File

@ -34,19 +34,12 @@ module Petstore
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'id' => :'id',
:'pet_id' => :'petId',
:'quantity' => :'quantity',
:'ship_date' => :'shipDate',
:'status' => :'status',
:'complete' => :'complete'
}
end
@ -54,12 +47,11 @@ module Petstore
def self.swagger_types
{
:'id' => :'Integer',
:'pet_id' => :'Integer',
:'quantity' => :'Integer',
:'ship_date' => :'DateTime',
:'status' => :'String',
:'complete' => :'BOOLEAN'
:'pet_id' => :'Integer',
:'quantity' => :'Integer',
:'ship_date' => :'DateTime',
:'status' => :'String',
:'complete' => :'BOOLEAN'
}
end
@ -71,31 +63,24 @@ module Petstore
# convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes[:'id']
self.id = attributes[:'id']
end
if attributes[:'petId']
self.pet_id = attributes[:'petId']
end
if attributes[:'quantity']
self.quantity = attributes[:'quantity']
end
if attributes[:'shipDate']
self.ship_date = attributes[:'shipDate']
end
if attributes[:'status']
self.status = attributes[:'status']
end
if attributes[:'complete']
self.complete = attributes[:'complete']
end
end
# Custom attribute writer method checking allowed values (enum).

View File

@ -34,19 +34,12 @@ module Petstore
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'id' => :'id',
:'category' => :'category',
:'name' => :'name',
:'photo_urls' => :'photoUrls',
:'tags' => :'tags',
:'status' => :'status'
}
end
@ -54,12 +47,11 @@ module Petstore
def self.swagger_types
{
:'id' => :'Integer',
:'category' => :'Category',
:'name' => :'String',
:'photo_urls' => :'Array<String>',
:'tags' => :'Array<Tag>',
:'status' => :'String'
:'category' => :'Category',
:'name' => :'String',
:'photo_urls' => :'Array<String>',
:'tags' => :'Array<Tag>',
:'status' => :'String'
}
end
@ -71,35 +63,28 @@ module Petstore
# convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes[:'id']
self.id = attributes[:'id']
end
if attributes[:'category']
self.category = attributes[:'category']
end
if attributes[:'name']
self.name = attributes[:'name']
end
if attributes[:'photoUrls']
if (value = attributes[:'photoUrls']).is_a?(Array)
self.photo_urls = value
end
end
if attributes[:'tags']
if (value = attributes[:'tags']).is_a?(Array)
self.tags = value
end
end
if attributes[:'status']
self.status = attributes[:'status']
end
end
# Custom attribute writer method checking allowed values (enum).

View File

@ -23,9 +23,7 @@ module Petstore
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'special_property_name' => :'$special[property.name]'
}
end
@ -33,7 +31,6 @@ module Petstore
def self.swagger_types
{
:'special_property_name' => :'Integer'
}
end
@ -45,11 +42,9 @@ module Petstore
# convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes[:'$special[property.name]']
self.special_property_name = attributes[:'$special[property.name]']
end
end
# Checks equality by comparing each attribute.

View File

@ -25,11 +25,8 @@ module Petstore
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'id' => :'id',
:'name' => :'name'
}
end
@ -37,8 +34,7 @@ module Petstore
def self.swagger_types
{
:'id' => :'Integer',
:'name' => :'String'
:'name' => :'String'
}
end
@ -50,15 +46,12 @@ module Petstore
# convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes[:'id']
self.id = attributes[:'id']
end
if attributes[:'name']
self.name = attributes[:'name']
end
end
# Checks equality by comparing each attribute.

View File

@ -38,23 +38,14 @@ module Petstore
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'id' => :'id',
:'username' => :'username',
:'first_name' => :'firstName',
:'last_name' => :'lastName',
:'email' => :'email',
:'password' => :'password',
:'phone' => :'phone',
:'user_status' => :'userStatus'
}
end
@ -62,14 +53,13 @@ module Petstore
def self.swagger_types
{
:'id' => :'Integer',
:'username' => :'String',
:'first_name' => :'String',
:'last_name' => :'String',
:'email' => :'String',
:'password' => :'String',
:'phone' => :'String',
:'user_status' => :'Integer'
:'username' => :'String',
:'first_name' => :'String',
:'last_name' => :'String',
:'email' => :'String',
:'password' => :'String',
:'phone' => :'String',
:'user_status' => :'Integer'
}
end
@ -81,39 +71,30 @@ module Petstore
# convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes[:'id']
self.id = attributes[:'id']
end
if attributes[:'username']
self.username = attributes[:'username']
end
if attributes[:'firstName']
self.first_name = attributes[:'firstName']
end
if attributes[:'lastName']
self.last_name = attributes[:'lastName']
end
if attributes[:'email']
self.email = attributes[:'email']
end
if attributes[:'password']
self.password = attributes[:'password']
end
if attributes[:'phone']
self.phone = attributes[:'phone']
end
if attributes[:'userStatus']
self.user_status = attributes[:'userStatus']
end
end
# Checks equality by comparing each attribute.

View File

@ -100,7 +100,7 @@ describe 'StoreApi' do
# unit tests for get_order_by_id
# Find purchase order by ID
# For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
# For valid response try integer IDs with value &lt;&#x3D; 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 [Order]

View File

@ -103,7 +103,7 @@ describe 'UserApi' do
# unit tests for get_user_by_name
# Get user by user name
#
# @param username The name that needs to be fetched. Use user1 for testing.
# @param username The name that needs to be fetched. Use user1 for testing.
# @param [Hash] opts the optional parameters
# @return [User]
describe 'get_user_by_name test' do