forked from loafle/openapi-generator-original
Merge pull request #2464 from wing328/ruby_improvement
[Ruby] minor ruby code improvement
This commit is contained in:
10
.gitignore
vendored
10
.gitignore
vendored
@@ -55,6 +55,12 @@ samples/client/petstore/qt5cpp/PetStore/Makefile
|
||||
**/.gradle/
|
||||
samples/client/petstore/java/hello.txt
|
||||
samples/client/petstore/android/default/hello.txt
|
||||
samples/client/petstore/android/volley/.gradle/
|
||||
samples/client/petstore/android/volley/build/
|
||||
samples/client/petstore/java/jersey2/.gradle/
|
||||
samples/client/petstore/java/jersey2/build/
|
||||
samples/client/petstore/java/okhttp-gson/.gradle/
|
||||
samples/client/petstore/java/okhttp-gson/build/
|
||||
|
||||
#PHP
|
||||
samples/client/petstore/php/SwaggerClient-php/composer.lock
|
||||
@@ -87,6 +93,10 @@ samples/client/petstore/csharp/SwaggerClientTest/bin
|
||||
samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/vendor/
|
||||
samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/
|
||||
samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/
|
||||
samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/nuget.exe
|
||||
samples/client/petstore/csharp/SwaggerClientTest/TestResult.xml
|
||||
samples/client/petstore/csharp/SwaggerClientTest/nuget.exe
|
||||
samples/client/petstore/csharp/SwaggerClientTest/testrunner/
|
||||
|
||||
# Python
|
||||
*.pyc
|
||||
|
||||
@@ -21,7 +21,7 @@ module {{moduleName}}
|
||||
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||
{{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}]
|
||||
def {{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
|
||||
{{#returnType}}data, status_code, headers = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts)
|
||||
{{#returnType}}data, _status_code, _headers = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts)
|
||||
{{#returnType}}return data{{/returnType}}{{^returnType}}return nil{{/returnType}}
|
||||
end
|
||||
|
||||
@@ -58,12 +58,12 @@ module {{moduleName}}
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = [{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = [{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type){{#headerParams}}{{#required}}
|
||||
local_header_content_type = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type){{#headerParams}}{{#required}}
|
||||
header_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}}{{/required}}{{/headerParams}}{{#headerParams}}{{^required}}
|
||||
header_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if opts[:'{{{paramName}}}']{{/required}}{{/headerParams}}
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ module {{moduleName}}
|
||||
# @return [Hash]
|
||||
attr_accessor :default_headers
|
||||
|
||||
# Initializes the ApiClient
|
||||
# @option config [Configuration] Configuraiton for initializing the object, default to Configuration.default
|
||||
def initialize(config = Configuration.default)
|
||||
@config = config
|
||||
@user_agent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/#{VERSION}/ruby{{/httpUserAgent}}"
|
||||
@@ -59,6 +61,15 @@ module {{moduleName}}
|
||||
return data, response.code, response.headers
|
||||
end
|
||||
|
||||
# Builds the HTTP request
|
||||
#
|
||||
# @param [String] http_method HTTP method/verb (e.g. POST)
|
||||
# @param [String] path URL path (e.g. /account/new)
|
||||
# @option opts [Hash] :header_params Header parameters
|
||||
# @option opts [Hash] :query_params Query parameters
|
||||
# @option opts [Hash] :form_params Query parameters
|
||||
# @option opts [Object] :body HTTP body (JSON/XML)
|
||||
# @return [Typhoeus::Request] A Typhoeus Request
|
||||
def build_request(http_method, path, opts = {})
|
||||
url = build_request_url(path)
|
||||
http_method = http_method.to_sym.downcase
|
||||
@@ -100,12 +111,15 @@ module {{moduleName}}
|
||||
# application/json
|
||||
# application/json; charset=UTF8
|
||||
# APPLICATION/JSON
|
||||
# @param [String] mime MIME
|
||||
# @return [Boolean] True if the MIME is applicaton/json
|
||||
def json_mime?(mime)
|
||||
!!(mime =~ /\Aapplication\/json(;.*)?\z/i)
|
||||
!(mime =~ /\Aapplication\/json(;.*)?\z/i).nil?
|
||||
end
|
||||
|
||||
# Deserialize the response to the given return type.
|
||||
#
|
||||
# @param [Response] response HTTP response
|
||||
# @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
|
||||
def deserialize(response, return_type)
|
||||
body = response.body
|
||||
@@ -136,6 +150,9 @@ module {{moduleName}}
|
||||
end
|
||||
|
||||
# Convert data to the given return type.
|
||||
# @param [Object] data Data to be converted
|
||||
# @param [String] return_type Return type
|
||||
# @return [Mixed] Data in a particular type
|
||||
def convert_to_type(data, return_type)
|
||||
return nil if data.nil?
|
||||
case return_type
|
||||
@@ -208,7 +225,7 @@ module {{moduleName}}
|
||||
# @param [String] filename the filename to be sanitized
|
||||
# @return [String] the sanitized filename
|
||||
def sanitize_filename(filename)
|
||||
filename.gsub /.*[\/\\]/, ''
|
||||
filename.gsub(/.*[\/\\]/, '')
|
||||
end
|
||||
|
||||
def build_request_url(path)
|
||||
@@ -217,6 +234,12 @@ module {{moduleName}}
|
||||
URI.encode(@config.base_url + path)
|
||||
end
|
||||
|
||||
# Builds the HTTP request body
|
||||
#
|
||||
# @param [Hash] header_params Header parameters
|
||||
# @param [Hash] form_params Query parameters
|
||||
# @param [Object] body HTTP body (JSON/XML)
|
||||
# @return [String] HTTP body data in the form of string
|
||||
def build_request_body(header_params, form_params, body)
|
||||
# http form
|
||||
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
||||
@@ -240,6 +263,10 @@ module {{moduleName}}
|
||||
end
|
||||
|
||||
# Update hearder and query params based on authentication settings.
|
||||
#
|
||||
# @param [Hash] header_params Header parameters
|
||||
# @param [Hash] form_params Query parameters
|
||||
# @param [String] auth_names Authentication scheme name
|
||||
def update_params_for_auth!(header_params, query_params, auth_names)
|
||||
Array(auth_names).each do |auth_name|
|
||||
auth_setting = @config.auth_settings[auth_name]
|
||||
@@ -252,6 +279,9 @@ module {{moduleName}}
|
||||
end
|
||||
end
|
||||
|
||||
# Sets user agent in HTTP header
|
||||
#
|
||||
# @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
|
||||
def user_agent=(user_agent)
|
||||
@user_agent = user_agent
|
||||
@default_headers['User-Agent'] = @user_agent
|
||||
@@ -283,13 +313,13 @@ module {{moduleName}}
|
||||
# @return [String] JSON string representation of the object
|
||||
def object_to_http_body(model)
|
||||
return model if model.nil? || model.is_a?(String)
|
||||
_body = nil
|
||||
local_body = nil
|
||||
if model.is_a?(Array)
|
||||
_body = model.map{|m| object_to_hash(m) }
|
||||
local_body = model.map{|m| object_to_hash(m) }
|
||||
else
|
||||
_body = object_to_hash(model)
|
||||
local_body = object_to_hash(model)
|
||||
end
|
||||
_body.to_json
|
||||
local_body.to_json
|
||||
end
|
||||
|
||||
# Convert object(non-array) to hash.
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
# 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
|
||||
@@ -51,21 +55,25 @@
|
||||
end
|
||||
end
|
||||
else # model
|
||||
_model = {{moduleName}}.const_get(type).new
|
||||
_model.build_from_hash(value)
|
||||
temp_model = {{moduleName}}.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|
|
||||
@@ -76,8 +84,10 @@
|
||||
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) }
|
||||
|
||||
@@ -28,11 +28,13 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}}
|
||||
}
|
||||
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}
|
||||
|
||||
{{#vars}}
|
||||
if attributes[:'{{{baseName}}}']
|
||||
@@ -46,6 +48,7 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}}
|
||||
end
|
||||
{{#vars}}{{#isEnum}}
|
||||
# Custom attribute writer method checking allowed values (enum).
|
||||
# @param [Object] {{{name}}} Object to be assigned
|
||||
def {{{name}}}=({{{name}}})
|
||||
allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
|
||||
if {{{name}}} && !allowed_values.include?({{{name}}})
|
||||
@@ -54,7 +57,8 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}}
|
||||
@{{{name}}} = {{{name}}}
|
||||
end
|
||||
{{/isEnum}}{{/vars}}
|
||||
# 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{{#vars}} &&
|
||||
@@ -62,11 +66,13 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}}
|
||||
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
|
||||
[{{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}].hash
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/
|
||||
|
||||
- API version: 1.0.0
|
||||
- Package version: 1.0.0
|
||||
- Build date: 2016-03-30T20:58:00.549+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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -54,19 +54,18 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = ['application/json', 'application/xml']
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = ['application/json', 'application/xml']
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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 = {}
|
||||
@@ -110,19 +109,18 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = ['application/json', 'application/xml']
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = ['application/json', 'application/xml']
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -171,12 +169,12 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
header_params[:'api_key'] = opts[:'api_key'] if opts[:'api_key']
|
||||
|
||||
# form parameters
|
||||
@@ -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,
|
||||
@@ -204,7 +201,7 @@ module Petstore
|
||||
# @option opts [Array<String>] :status Status values that need to be considered for query (default to available)
|
||||
# @return [Array<Pet>]
|
||||
def find_pets_by_status(opts = {})
|
||||
data, status_code, headers = find_pets_by_status_with_http_info(opts)
|
||||
data, _status_code, _headers = find_pets_by_status_with_http_info(opts)
|
||||
return data
|
||||
end
|
||||
|
||||
@@ -229,20 +226,19 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -262,7 +258,7 @@ module Petstore
|
||||
# @option opts [Array<String>] :tags Tags to filter by
|
||||
# @return [Array<Pet>]
|
||||
def find_pets_by_tags(opts = {})
|
||||
data, status_code, headers = find_pets_by_tags_with_http_info(opts)
|
||||
data, _status_code, _headers = find_pets_by_tags_with_http_info(opts)
|
||||
return data
|
||||
end
|
||||
|
||||
@@ -287,20 +283,19 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -320,7 +315,7 @@ module Petstore
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Pet]
|
||||
def get_pet_by_id(pet_id, opts = {})
|
||||
data, status_code, headers = get_pet_by_id_with_http_info(pet_id, opts)
|
||||
data, _status_code, _headers = get_pet_by_id_with_http_info(pet_id, opts)
|
||||
return data
|
||||
end
|
||||
|
||||
@@ -347,20 +342,19 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -380,7 +374,7 @@ module Petstore
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [InlineResponse200]
|
||||
def get_pet_by_id_in_object(pet_id, opts = {})
|
||||
data, status_code, headers = get_pet_by_id_in_object_with_http_info(pet_id, opts)
|
||||
data, _status_code, _headers = get_pet_by_id_in_object_with_http_info(pet_id, opts)
|
||||
return data
|
||||
end
|
||||
|
||||
@@ -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 = {}
|
||||
@@ -407,20 +401,19 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -440,7 +433,7 @@ module Petstore
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [String]
|
||||
def pet_pet_idtesting_byte_arraytrue_get(pet_id, opts = {})
|
||||
data, status_code, headers = pet_pet_idtesting_byte_arraytrue_get_with_http_info(pet_id, opts)
|
||||
data, _status_code, _headers = pet_pet_idtesting_byte_arraytrue_get_with_http_info(pet_id, opts)
|
||||
return data
|
||||
end
|
||||
|
||||
@@ -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 = {}
|
||||
@@ -467,20 +460,19 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -524,19 +516,18 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = ['application/json', 'application/xml']
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = ['application/json', 'application/xml']
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -587,12 +578,12 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = ['application/x-www-form-urlencoded']
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = ['application/x-www-form-urlencoded']
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_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,
|
||||
@@ -652,12 +642,12 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = ['multipart/form-data']
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = ['multipart/form-data']
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_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,
|
||||
|
||||
@@ -57,20 +57,19 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -89,7 +88,7 @@ module Petstore
|
||||
# @option opts [String] :status Status value that needs to be considered for query (default to placed)
|
||||
# @return [Array<Order>]
|
||||
def find_orders_by_status(opts = {})
|
||||
data, status_code, headers = find_orders_by_status_with_http_info(opts)
|
||||
data, _status_code, _headers = find_orders_by_status_with_http_info(opts)
|
||||
return data
|
||||
end
|
||||
|
||||
@@ -118,20 +117,19 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -150,7 +148,7 @@ module Petstore
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Hash<String, Integer>]
|
||||
def get_inventory(opts = {})
|
||||
data, status_code, headers = get_inventory_with_http_info(opts)
|
||||
data, _status_code, _headers = get_inventory_with_http_info(opts)
|
||||
return data
|
||||
end
|
||||
|
||||
@@ -173,20 +171,19 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -205,7 +202,7 @@ module Petstore
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Object]
|
||||
def get_inventory_in_object(opts = {})
|
||||
data, status_code, headers = get_inventory_in_object_with_http_info(opts)
|
||||
data, _status_code, _headers = get_inventory_in_object_with_http_info(opts)
|
||||
return data
|
||||
end
|
||||
|
||||
@@ -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 = {}
|
||||
@@ -228,20 +225,19 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -261,12 +257,12 @@ module Petstore
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Order]
|
||||
def get_order_by_id(order_id, opts = {})
|
||||
data, status_code, headers = get_order_by_id_with_http_info(order_id, opts)
|
||||
data, _status_code, _headers = get_order_by_id_with_http_info(order_id, opts)
|
||||
return data
|
||||
end
|
||||
|
||||
# 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
|
||||
@@ -288,20 +284,19 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -321,7 +316,7 @@ module Petstore
|
||||
# @option opts [Order] :body order placed for purchasing the pet
|
||||
# @return [Order]
|
||||
def place_order(opts = {})
|
||||
data, status_code, headers = place_order_with_http_info(opts)
|
||||
data, _status_code, _headers = place_order_with_http_info(opts)
|
||||
return data
|
||||
end
|
||||
|
||||
@@ -345,19 +340,18 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
|
||||
@@ -54,19 +54,18 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -110,19 +109,18 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -166,19 +164,18 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -225,20 +222,19 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,17 +249,17 @@ 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 = {})
|
||||
data, status_code, headers = get_user_by_name_with_http_info(username, opts)
|
||||
data, _status_code, _headers = get_user_by_name_with_http_info(username, opts)
|
||||
return data
|
||||
end
|
||||
|
||||
# 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 = {})
|
||||
@@ -284,20 +280,19 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -318,7 +313,7 @@ module Petstore
|
||||
# @option opts [String] :password The password for login in clear text
|
||||
# @return [String]
|
||||
def login_user(opts = {})
|
||||
data, status_code, headers = login_user_with_http_info(opts)
|
||||
data, _status_code, _headers = login_user_with_http_info(opts)
|
||||
return data
|
||||
end
|
||||
|
||||
@@ -345,20 +340,19 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -400,20 +394,19 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
@@ -461,19 +454,18 @@ module Petstore
|
||||
header_params = {}
|
||||
|
||||
# HTTP header 'Accept' (if needed)
|
||||
_header_accept = ['application/json', 'application/xml']
|
||||
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
|
||||
local_header_accept = ['application/json', 'application/xml']
|
||||
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||
|
||||
# HTTP header 'Content-Type'
|
||||
_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
|
||||
local_header_content_type = []
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||
|
||||
# form parameters
|
||||
form_params = {}
|
||||
|
||||
# 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,
|
||||
|
||||
@@ -31,6 +31,8 @@ module Petstore
|
||||
# @return [Hash]
|
||||
attr_accessor :default_headers
|
||||
|
||||
# Initializes the ApiClient
|
||||
# @option config [Configuration] Configuraiton for initializing the object, default to Configuration.default
|
||||
def initialize(config = Configuration.default)
|
||||
@config = config
|
||||
@user_agent = "Swagger-Codegen/#{VERSION}/ruby"
|
||||
@@ -71,6 +73,15 @@ module Petstore
|
||||
return data, response.code, response.headers
|
||||
end
|
||||
|
||||
# Builds the HTTP request
|
||||
#
|
||||
# @param [String] http_method HTTP method/verb (e.g. POST)
|
||||
# @param [String] path URL path (e.g. /account/new)
|
||||
# @option opts [Hash] :header_params Header parameters
|
||||
# @option opts [Hash] :query_params Query parameters
|
||||
# @option opts [Hash] :form_params Query parameters
|
||||
# @option opts [Object] :body HTTP body (JSON/XML)
|
||||
# @return [Typhoeus::Request] A Typhoeus Request
|
||||
def build_request(http_method, path, opts = {})
|
||||
url = build_request_url(path)
|
||||
http_method = http_method.to_sym.downcase
|
||||
@@ -79,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,
|
||||
@@ -112,12 +121,15 @@ module Petstore
|
||||
# application/json
|
||||
# application/json; charset=UTF8
|
||||
# APPLICATION/JSON
|
||||
# @param [String] mime MIME
|
||||
# @return [Boolean] True if the MIME is applicaton/json
|
||||
def json_mime?(mime)
|
||||
!!(mime =~ /\Aapplication\/json(;.*)?\z/i)
|
||||
!(mime =~ /\Aapplication\/json(;.*)?\z/i).nil?
|
||||
end
|
||||
|
||||
# Deserialize the response to the given return type.
|
||||
#
|
||||
# @param [Response] response HTTP response
|
||||
# @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
|
||||
def deserialize(response, return_type)
|
||||
body = response.body
|
||||
@@ -148,6 +160,9 @@ module Petstore
|
||||
end
|
||||
|
||||
# Convert data to the given return type.
|
||||
# @param [Object] data Data to be converted
|
||||
# @param [String] return_type Return type
|
||||
# @return [Mixed] Data in a particular type
|
||||
def convert_to_type(data, return_type)
|
||||
return nil if data.nil?
|
||||
case return_type
|
||||
@@ -220,7 +235,7 @@ module Petstore
|
||||
# @param [String] filename the filename to be sanitized
|
||||
# @return [String] the sanitized filename
|
||||
def sanitize_filename(filename)
|
||||
filename.gsub /.*[\/\\]/, ''
|
||||
filename.gsub(/.*[\/\\]/, '')
|
||||
end
|
||||
|
||||
def build_request_url(path)
|
||||
@@ -229,6 +244,12 @@ module Petstore
|
||||
URI.encode(@config.base_url + path)
|
||||
end
|
||||
|
||||
# Builds the HTTP request body
|
||||
#
|
||||
# @param [Hash] header_params Header parameters
|
||||
# @param [Hash] form_params Query parameters
|
||||
# @param [Object] body HTTP body (JSON/XML)
|
||||
# @return [String] HTTP body data in the form of string
|
||||
def build_request_body(header_params, form_params, body)
|
||||
# http form
|
||||
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
||||
@@ -252,6 +273,10 @@ module Petstore
|
||||
end
|
||||
|
||||
# Update hearder and query params based on authentication settings.
|
||||
#
|
||||
# @param [Hash] header_params Header parameters
|
||||
# @param [Hash] form_params Query parameters
|
||||
# @param [String] auth_names Authentication scheme name
|
||||
def update_params_for_auth!(header_params, query_params, auth_names)
|
||||
Array(auth_names).each do |auth_name|
|
||||
auth_setting = @config.auth_settings[auth_name]
|
||||
@@ -264,6 +289,9 @@ module Petstore
|
||||
end
|
||||
end
|
||||
|
||||
# Sets user agent in HTTP header
|
||||
#
|
||||
# @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
|
||||
def user_agent=(user_agent)
|
||||
@user_agent = user_agent
|
||||
@default_headers['User-Agent'] = @user_agent
|
||||
@@ -295,13 +323,13 @@ module Petstore
|
||||
# @return [String] JSON string representation of the object
|
||||
def object_to_http_body(model)
|
||||
return model if model.nil? || model.is_a?(String)
|
||||
_body = nil
|
||||
local_body = nil
|
||||
if model.is_a?(Array)
|
||||
_body = model.map{|m| object_to_hash(m) }
|
||||
local_body = model.map{|m| object_to_hash(m) }
|
||||
else
|
||||
_body = object_to_hash(model)
|
||||
local_body = object_to_hash(model)
|
||||
end
|
||||
_body.to_json
|
||||
local_body.to_json
|
||||
end
|
||||
|
||||
# Convert object(non-array) to hash.
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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,29 +34,28 @@ module Petstore
|
||||
def self.swagger_types
|
||||
{
|
||||
:'id' => :'Integer',
|
||||
:'name' => :'String'
|
||||
|
||||
:'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[:'id']
|
||||
self.id = attributes[:'id']
|
||||
end
|
||||
|
||||
if attributes[:'name']
|
||||
self.name = attributes[:'name']
|
||||
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
|
||||
[id, 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
|
||||
@@ -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) }
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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,53 +47,48 @@ 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
|
||||
|
||||
# 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[:'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).
|
||||
# @param [Object] status Object to be assigned
|
||||
def status=(status)
|
||||
allowed_values = ["available", "pending", "sold"]
|
||||
if status && !allowed_values.include?(status)
|
||||
@@ -109,7 +97,8 @@ module Petstore
|
||||
@status = status
|
||||
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 &&
|
||||
@@ -122,35 +111,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
|
||||
[tags, id, category, status, name, photo_urls].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
|
||||
@@ -184,21 +179,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|
|
||||
@@ -209,8 +208,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) }
|
||||
|
||||
@@ -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,24 +32,24 @@ module Petstore
|
||||
def self.swagger_types
|
||||
{
|
||||
:'name' => :'Integer'
|
||||
|
||||
}
|
||||
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[:'name']
|
||||
self.name = attributes[:'name']
|
||||
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 +57,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
|
||||
[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 +125,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 +154,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) }
|
||||
|
||||
@@ -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,24 +32,24 @@ module Petstore
|
||||
def self.swagger_types
|
||||
{
|
||||
:'_return' => :'Integer'
|
||||
|
||||
}
|
||||
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[:'return']
|
||||
self._return = attributes[:'return']
|
||||
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 +57,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
|
||||
[_return].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 +125,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 +154,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) }
|
||||
|
||||
@@ -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,29 +35,28 @@ module Petstore
|
||||
def self.swagger_types
|
||||
{
|
||||
:'name' => :'Integer',
|
||||
:'snake_case' => :'Integer'
|
||||
|
||||
:'snake_case' => :'Integer'
|
||||
}
|
||||
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[:'name']
|
||||
self.name = attributes[:'name']
|
||||
end
|
||||
|
||||
if attributes[:'snake_case']
|
||||
self.snake_case = attributes[:'snake_case']
|
||||
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 +65,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
|
||||
[name, snake_case].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 +133,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 +162,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) }
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
=begin
|
||||
Swagger Petstore
|
||||
|
||||
This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Contact: apiteam@swagger.io
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
|
||||
License: Apache 2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
Terms of Service: http://swagger.io/terms/
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class ObjectReturn
|
||||
attr_accessor :_return
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
|
||||
:'_return' => :'return'
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.swagger_types
|
||||
{
|
||||
:'_return' => :'Integer'
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
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}
|
||||
|
||||
|
||||
if attributes[:'return']
|
||||
self._return = attributes[:'return']
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Check equality by comparing each attribute.
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
_return == o._return
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculate hash code according to all attributes.
|
||||
def hash
|
||||
[_return].hash
|
||||
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 :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :BOOLEAN
|
||||
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
_model = Petstore.const_get(type).new
|
||||
_model.build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_body (backward compatibility))
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# return the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
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.is_a?(Array)
|
||||
value.compact.map{ |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -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,49 +47,44 @@ 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
|
||||
|
||||
# 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[:'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).
|
||||
# @param [Object] status Object to be assigned
|
||||
def status=(status)
|
||||
allowed_values = ["placed", "approved", "delivered"]
|
||||
if status && !allowed_values.include?(status)
|
||||
@@ -105,7 +93,8 @@ module Petstore
|
||||
@status = status
|
||||
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 &&
|
||||
@@ -118,35 +107,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
|
||||
[id, pet_id, quantity, ship_date, status, complete].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
|
||||
@@ -180,21 +175,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|
|
||||
@@ -205,8 +204,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) }
|
||||
|
||||
@@ -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,53 +47,48 @@ 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
|
||||
|
||||
# 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[:'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).
|
||||
# @param [Object] status Object to be assigned
|
||||
def status=(status)
|
||||
allowed_values = ["available", "pending", "sold"]
|
||||
if status && !allowed_values.include?(status)
|
||||
@@ -109,7 +97,8 @@ module Petstore
|
||||
@status = status
|
||||
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 &&
|
||||
@@ -122,35 +111,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
|
||||
[id, category, name, photo_urls, tags, status].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
|
||||
@@ -184,21 +179,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|
|
||||
@@ -209,8 +208,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) }
|
||||
|
||||
@@ -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,24 +31,24 @@ module Petstore
|
||||
def self.swagger_types
|
||||
{
|
||||
:'special_property_name' => :'Integer'
|
||||
|
||||
}
|
||||
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[:'$special[property.name]']
|
||||
self.special_property_name = attributes[:'$special[property.name]']
|
||||
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
|
||||
[special_property_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) }
|
||||
|
||||
@@ -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,29 +34,28 @@ module Petstore
|
||||
def self.swagger_types
|
||||
{
|
||||
:'id' => :'Integer',
|
||||
:'name' => :'String'
|
||||
|
||||
:'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[:'id']
|
||||
self.id = attributes[:'id']
|
||||
end
|
||||
|
||||
if attributes[:'name']
|
||||
self.name = attributes[:'name']
|
||||
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
|
||||
[id, 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
|
||||
@@ -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) }
|
||||
|
||||
@@ -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,59 +53,52 @@ 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
|
||||
|
||||
# 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[:'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
|
||||
|
||||
# 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 &&
|
||||
@@ -129,35 +113,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
|
||||
[id, username, first_name, last_name, email, password, phone, user_status].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
|
||||
@@ -191,21 +181,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|
|
||||
@@ -216,8 +210,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) }
|
||||
|
||||
@@ -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 <= 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 [Order]
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user