mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-19 10:47:06 +00:00
[ruby] Introduce ApiModelBase (#22052)
The Ruby code that is generated copies numerous methods into every model. This creates bloat both in file size and run-time memory usage. This commit introduces a base class for all models to store common methods. This commit's focus is only on static methods that do not change between models.
This commit is contained in:
@@ -271,6 +271,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
|||||||
supportingFiles.add(new SupportingFile("gem.mustache", libFolder, gemName + ".rb"));
|
supportingFiles.add(new SupportingFile("gem.mustache", libFolder, gemName + ".rb"));
|
||||||
String gemFolder = libFolder + File.separator + gemName;
|
String gemFolder = libFolder + File.separator + gemName;
|
||||||
supportingFiles.add(new SupportingFile("api_error.mustache", gemFolder, "api_error.rb"));
|
supportingFiles.add(new SupportingFile("api_error.mustache", gemFolder, "api_error.rb"));
|
||||||
|
supportingFiles.add(new SupportingFile("api_model_base.mustache", gemFolder, "api_model_base.rb"));
|
||||||
supportingFiles.add(new SupportingFile("version.mustache", gemFolder, "version.rb"));
|
supportingFiles.add(new SupportingFile("version.mustache", gemFolder, "version.rb"));
|
||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||||
|
|||||||
81
modules/openapi-generator/src/main/resources/ruby-client/api_model_base.mustache
vendored
Normal file
81
modules/openapi-generator/src/main/resources/ruby-client/api_model_base.mustache
vendored
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
=begin
|
||||||
|
{{> api_info}}
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
module {{moduleName}}
|
||||||
|
class ApiModelBase
|
||||||
|
# Deserializes the data based on type
|
||||||
|
# @param string type Data type
|
||||||
|
# @param string value Value to be deserialized
|
||||||
|
# @return [Object] Deserialized data
|
||||||
|
def self._deserialize(type, value)
|
||||||
|
case type.to_sym
|
||||||
|
when :Time
|
||||||
|
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
||||||
|
# models (e.g. Pet) or oneOf
|
||||||
|
klass = {{moduleName}}.const_get(type)
|
||||||
|
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
||||||
|
# @return [Hash] Returns the object in the form of hash
|
||||||
|
def to_body
|
||||||
|
to_hash
|
||||||
|
end
|
||||||
|
|
||||||
|
# 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) }
|
||||||
|
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
|
||||||
@@ -24,61 +24,6 @@
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = {{moduleName}}.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -94,21 +39,3 @@
|
|||||||
end
|
end
|
||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
# Common files
|
# Common files
|
||||||
require '{{gemName}}/api_client'
|
require '{{gemName}}/api_client'
|
||||||
require '{{gemName}}/api_error'
|
require '{{gemName}}/api_error'
|
||||||
|
require '{{gemName}}/api_model_base'
|
||||||
require '{{gemName}}/version'
|
require '{{gemName}}/version'
|
||||||
require '{{gemName}}/configuration'
|
require '{{gemName}}/configuration'
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{{#description}}
|
{{#description}}
|
||||||
# {{{.}}}
|
# {{{.}}}
|
||||||
{{/description}}
|
{{/description}}
|
||||||
class {{classname}}{{#parent}} < {{{.}}}{{/parent}}
|
class {{classname}}{{#parent}} < {{{.}}}{{/parent}}{{^parent}} < ApiModelBase{{/parent}}
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{#description}}
|
{{#description}}
|
||||||
# {{{.}}}
|
# {{{.}}}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ lib/openapi_client/api/path_api.rb
|
|||||||
lib/openapi_client/api/query_api.rb
|
lib/openapi_client/api/query_api.rb
|
||||||
lib/openapi_client/api_client.rb
|
lib/openapi_client/api_client.rb
|
||||||
lib/openapi_client/api_error.rb
|
lib/openapi_client/api_error.rb
|
||||||
|
lib/openapi_client/api_model_base.rb
|
||||||
lib/openapi_client/configuration.rb
|
lib/openapi_client/configuration.rb
|
||||||
lib/openapi_client/models/bird.rb
|
lib/openapi_client/models/bird.rb
|
||||||
lib/openapi_client/models/category.rb
|
lib/openapi_client/models/category.rb
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ Generator version: 7.17.0-SNAPSHOT
|
|||||||
# Common files
|
# Common files
|
||||||
require 'openapi_client/api_client'
|
require 'openapi_client/api_client'
|
||||||
require 'openapi_client/api_error'
|
require 'openapi_client/api_error'
|
||||||
|
require 'openapi_client/api_model_base'
|
||||||
require 'openapi_client/version'
|
require 'openapi_client/version'
|
||||||
require 'openapi_client/configuration'
|
require 'openapi_client/configuration'
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
=begin
|
||||||
|
#Echo Server API
|
||||||
|
|
||||||
|
#Echo Server API
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 0.1.0
|
||||||
|
Contact: team@openapitools.org
|
||||||
|
Generated by: https://openapi-generator.tech
|
||||||
|
Generator version: 7.17.0-SNAPSHOT
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
module OpenapiClient
|
||||||
|
class ApiModelBase
|
||||||
|
# Deserializes the data based on type
|
||||||
|
# @param string type Data type
|
||||||
|
# @param string value Value to be deserialized
|
||||||
|
# @return [Object] Deserialized data
|
||||||
|
def self._deserialize(type, value)
|
||||||
|
case type.to_sym
|
||||||
|
when :Time
|
||||||
|
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
||||||
|
# models (e.g. Pet) or oneOf
|
||||||
|
klass = OpenapiClient.const_get(type)
|
||||||
|
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
||||||
|
# @return [Hash] Returns the object in the form of hash
|
||||||
|
def to_body
|
||||||
|
to_hash
|
||||||
|
end
|
||||||
|
|
||||||
|
# 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) }
|
||||||
|
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
|
||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class Bird
|
class Bird < ApiModelBase
|
||||||
attr_accessor :size
|
attr_accessor :size
|
||||||
|
|
||||||
attr_accessor :color
|
attr_accessor :color
|
||||||
@@ -135,61 +135,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -206,24 +151,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class Category
|
class Category < ApiModelBase
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
@@ -135,61 +135,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -206,24 +151,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -180,61 +180,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -251,24 +196,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ require 'time'
|
|||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
# to test the default value of properties
|
# to test the default value of properties
|
||||||
class DefaultValue
|
class DefaultValue < ApiModelBase
|
||||||
attr_accessor :array_string_enum_ref_default
|
attr_accessor :array_string_enum_ref_default
|
||||||
|
|
||||||
attr_accessor :array_string_enum_default
|
attr_accessor :array_string_enum_default
|
||||||
@@ -229,61 +229,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -300,24 +245,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class NumberPropertiesOnly
|
class NumberPropertiesOnly < ApiModelBase
|
||||||
attr_accessor :number
|
attr_accessor :number
|
||||||
|
|
||||||
attr_accessor :float
|
attr_accessor :float
|
||||||
@@ -172,61 +172,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -243,24 +188,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class Pet
|
class Pet < ApiModelBase
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
@@ -244,61 +244,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -315,24 +260,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class Query
|
class Query < ApiModelBase
|
||||||
# Query
|
# Query
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
@@ -160,61 +160,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -231,24 +176,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class Tag
|
class Tag < ApiModelBase
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
@@ -135,61 +135,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -206,24 +151,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class TestFormObjectMultipartRequestMarker
|
class TestFormObjectMultipartRequestMarker < ApiModelBase
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -126,61 +126,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -197,24 +142,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter < ApiModelBase
|
||||||
attr_accessor :size
|
attr_accessor :size
|
||||||
|
|
||||||
attr_accessor :color
|
attr_accessor :color
|
||||||
@@ -161,61 +161,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -232,24 +177,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
|
class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter < ApiModelBase
|
||||||
attr_accessor :values
|
attr_accessor :values
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -128,61 +128,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -199,24 +144,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ lib/openapi_client/api/path_api.rb
|
|||||||
lib/openapi_client/api/query_api.rb
|
lib/openapi_client/api/query_api.rb
|
||||||
lib/openapi_client/api_client.rb
|
lib/openapi_client/api_client.rb
|
||||||
lib/openapi_client/api_error.rb
|
lib/openapi_client/api_error.rb
|
||||||
|
lib/openapi_client/api_model_base.rb
|
||||||
lib/openapi_client/configuration.rb
|
lib/openapi_client/configuration.rb
|
||||||
lib/openapi_client/models/bird.rb
|
lib/openapi_client/models/bird.rb
|
||||||
lib/openapi_client/models/category.rb
|
lib/openapi_client/models/category.rb
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ Generator version: 7.17.0-SNAPSHOT
|
|||||||
# Common files
|
# Common files
|
||||||
require 'openapi_client/api_client'
|
require 'openapi_client/api_client'
|
||||||
require 'openapi_client/api_error'
|
require 'openapi_client/api_error'
|
||||||
|
require 'openapi_client/api_model_base'
|
||||||
require 'openapi_client/version'
|
require 'openapi_client/version'
|
||||||
require 'openapi_client/configuration'
|
require 'openapi_client/configuration'
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
=begin
|
||||||
|
#Echo Server API
|
||||||
|
|
||||||
|
#Echo Server API
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 0.1.0
|
||||||
|
Contact: team@openapitools.org
|
||||||
|
Generated by: https://openapi-generator.tech
|
||||||
|
Generator version: 7.17.0-SNAPSHOT
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
module OpenapiClient
|
||||||
|
class ApiModelBase
|
||||||
|
# Deserializes the data based on type
|
||||||
|
# @param string type Data type
|
||||||
|
# @param string value Value to be deserialized
|
||||||
|
# @return [Object] Deserialized data
|
||||||
|
def self._deserialize(type, value)
|
||||||
|
case type.to_sym
|
||||||
|
when :Time
|
||||||
|
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
||||||
|
# models (e.g. Pet) or oneOf
|
||||||
|
klass = OpenapiClient.const_get(type)
|
||||||
|
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
||||||
|
# @return [Hash] Returns the object in the form of hash
|
||||||
|
def to_body
|
||||||
|
to_hash
|
||||||
|
end
|
||||||
|
|
||||||
|
# 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) }
|
||||||
|
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
|
||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class Bird
|
class Bird < ApiModelBase
|
||||||
attr_accessor :size
|
attr_accessor :size
|
||||||
|
|
||||||
attr_accessor :color
|
attr_accessor :color
|
||||||
@@ -135,61 +135,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -206,24 +151,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class Category
|
class Category < ApiModelBase
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
@@ -135,61 +135,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -206,24 +151,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -180,61 +180,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -251,24 +196,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ require 'time'
|
|||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
# to test the default value of properties
|
# to test the default value of properties
|
||||||
class DefaultValue
|
class DefaultValue < ApiModelBase
|
||||||
attr_accessor :array_string_enum_ref_default
|
attr_accessor :array_string_enum_ref_default
|
||||||
|
|
||||||
attr_accessor :array_string_enum_default
|
attr_accessor :array_string_enum_default
|
||||||
@@ -229,61 +229,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -300,24 +245,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class NumberPropertiesOnly
|
class NumberPropertiesOnly < ApiModelBase
|
||||||
attr_accessor :number
|
attr_accessor :number
|
||||||
|
|
||||||
attr_accessor :float
|
attr_accessor :float
|
||||||
@@ -172,61 +172,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -243,24 +188,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class Pet
|
class Pet < ApiModelBase
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
@@ -244,61 +244,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -315,24 +260,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class Query
|
class Query < ApiModelBase
|
||||||
# Query
|
# Query
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
@@ -160,61 +160,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -231,24 +176,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class Tag
|
class Tag < ApiModelBase
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
@@ -135,61 +135,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -206,24 +151,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class TestFormObjectMultipartRequestMarker
|
class TestFormObjectMultipartRequestMarker < ApiModelBase
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -126,61 +126,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -197,24 +142,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter < ApiModelBase
|
||||||
attr_accessor :size
|
attr_accessor :size
|
||||||
|
|
||||||
attr_accessor :color
|
attr_accessor :color
|
||||||
@@ -161,61 +161,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -232,24 +177,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
|
class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter < ApiModelBase
|
||||||
attr_accessor :values
|
attr_accessor :values
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -128,61 +128,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -199,24 +144,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ lib/openapi_client/api/path_api.rb
|
|||||||
lib/openapi_client/api/query_api.rb
|
lib/openapi_client/api/query_api.rb
|
||||||
lib/openapi_client/api_client.rb
|
lib/openapi_client/api_client.rb
|
||||||
lib/openapi_client/api_error.rb
|
lib/openapi_client/api_error.rb
|
||||||
|
lib/openapi_client/api_model_base.rb
|
||||||
lib/openapi_client/configuration.rb
|
lib/openapi_client/configuration.rb
|
||||||
lib/openapi_client/models/bird.rb
|
lib/openapi_client/models/bird.rb
|
||||||
lib/openapi_client/models/category.rb
|
lib/openapi_client/models/category.rb
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ Generator version: 7.17.0-SNAPSHOT
|
|||||||
# Common files
|
# Common files
|
||||||
require 'openapi_client/api_client'
|
require 'openapi_client/api_client'
|
||||||
require 'openapi_client/api_error'
|
require 'openapi_client/api_error'
|
||||||
|
require 'openapi_client/api_model_base'
|
||||||
require 'openapi_client/version'
|
require 'openapi_client/version'
|
||||||
require 'openapi_client/configuration'
|
require 'openapi_client/configuration'
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
=begin
|
||||||
|
#Echo Server API
|
||||||
|
|
||||||
|
#Echo Server API
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 0.1.0
|
||||||
|
Contact: team@openapitools.org
|
||||||
|
Generated by: https://openapi-generator.tech
|
||||||
|
Generator version: 7.17.0-SNAPSHOT
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
module OpenapiClient
|
||||||
|
class ApiModelBase
|
||||||
|
# Deserializes the data based on type
|
||||||
|
# @param string type Data type
|
||||||
|
# @param string value Value to be deserialized
|
||||||
|
# @return [Object] Deserialized data
|
||||||
|
def self._deserialize(type, value)
|
||||||
|
case type.to_sym
|
||||||
|
when :Time
|
||||||
|
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
||||||
|
# models (e.g. Pet) or oneOf
|
||||||
|
klass = OpenapiClient.const_get(type)
|
||||||
|
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
||||||
|
# @return [Hash] Returns the object in the form of hash
|
||||||
|
def to_body
|
||||||
|
to_hash
|
||||||
|
end
|
||||||
|
|
||||||
|
# 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) }
|
||||||
|
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
|
||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class Bird
|
class Bird < ApiModelBase
|
||||||
attr_accessor :size
|
attr_accessor :size
|
||||||
|
|
||||||
attr_accessor :color
|
attr_accessor :color
|
||||||
@@ -135,61 +135,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -206,24 +151,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class Category
|
class Category < ApiModelBase
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
@@ -135,61 +135,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -206,24 +151,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -180,61 +180,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -251,24 +196,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ require 'time'
|
|||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
# to test the default value of properties
|
# to test the default value of properties
|
||||||
class DefaultValue
|
class DefaultValue < ApiModelBase
|
||||||
attr_accessor :array_string_enum_ref_default
|
attr_accessor :array_string_enum_ref_default
|
||||||
|
|
||||||
attr_accessor :array_string_enum_default
|
attr_accessor :array_string_enum_default
|
||||||
@@ -229,61 +229,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -300,24 +245,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class NumberPropertiesOnly
|
class NumberPropertiesOnly < ApiModelBase
|
||||||
attr_accessor :number
|
attr_accessor :number
|
||||||
|
|
||||||
attr_accessor :float
|
attr_accessor :float
|
||||||
@@ -172,61 +172,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -243,24 +188,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class Pet
|
class Pet < ApiModelBase
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
@@ -244,61 +244,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -315,24 +260,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class Query
|
class Query < ApiModelBase
|
||||||
# Query
|
# Query
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
@@ -160,61 +160,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -231,24 +176,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class Tag
|
class Tag < ApiModelBase
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
@@ -135,61 +135,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -206,24 +151,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class TestFormObjectMultipartRequestMarker
|
class TestFormObjectMultipartRequestMarker < ApiModelBase
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -126,61 +126,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -197,24 +142,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
|
class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter < ApiModelBase
|
||||||
attr_accessor :size
|
attr_accessor :size
|
||||||
|
|
||||||
attr_accessor :color
|
attr_accessor :color
|
||||||
@@ -161,61 +161,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -232,24 +177,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module OpenapiClient
|
module OpenapiClient
|
||||||
class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
|
class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter < ApiModelBase
|
||||||
attr_accessor :values
|
attr_accessor :values
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -128,61 +128,6 @@ module OpenapiClient
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = OpenapiClient.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -199,24 +144,6 @@ module OpenapiClient
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ lib/petstore/api/store_api.rb
|
|||||||
lib/petstore/api/user_api.rb
|
lib/petstore/api/user_api.rb
|
||||||
lib/petstore/api_client.rb
|
lib/petstore/api_client.rb
|
||||||
lib/petstore/api_error.rb
|
lib/petstore/api_error.rb
|
||||||
|
lib/petstore/api_model_base.rb
|
||||||
lib/petstore/configuration.rb
|
lib/petstore/configuration.rb
|
||||||
lib/petstore/models/additional_properties_class.rb
|
lib/petstore/models/additional_properties_class.rb
|
||||||
lib/petstore/models/all_of_with_single_ref.rb
|
lib/petstore/models/all_of_with_single_ref.rb
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ Generator version: 7.17.0-SNAPSHOT
|
|||||||
# Common files
|
# Common files
|
||||||
require 'petstore/api_client'
|
require 'petstore/api_client'
|
||||||
require 'petstore/api_error'
|
require 'petstore/api_error'
|
||||||
|
require 'petstore/api_model_base'
|
||||||
require 'petstore/version'
|
require 'petstore/version'
|
||||||
require 'petstore/configuration'
|
require 'petstore/configuration'
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
=begin
|
||||||
|
#OpenAPI Petstore
|
||||||
|
|
||||||
|
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
|
||||||
|
Generated by: https://openapi-generator.tech
|
||||||
|
Generator version: 7.17.0-SNAPSHOT
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
module Petstore
|
||||||
|
class ApiModelBase
|
||||||
|
# Deserializes the data based on type
|
||||||
|
# @param string type Data type
|
||||||
|
# @param string value Value to be deserialized
|
||||||
|
# @return [Object] Deserialized data
|
||||||
|
def self._deserialize(type, value)
|
||||||
|
case type.to_sym
|
||||||
|
when :Time
|
||||||
|
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
||||||
|
# models (e.g. Pet) or oneOf
|
||||||
|
klass = Petstore.const_get(type)
|
||||||
|
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
||||||
|
# @return [Hash] Returns the object in the form of hash
|
||||||
|
def to_body
|
||||||
|
to_hash
|
||||||
|
end
|
||||||
|
|
||||||
|
# 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) }
|
||||||
|
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
|
||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class AdditionalPropertiesClass
|
class AdditionalPropertiesClass < ApiModelBase
|
||||||
attr_accessor :map_property
|
attr_accessor :map_property
|
||||||
|
|
||||||
attr_accessor :map_of_map_property
|
attr_accessor :map_of_map_property
|
||||||
@@ -139,61 +139,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -210,24 +155,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class AllOfWithSingleRef
|
class AllOfWithSingleRef < ApiModelBase
|
||||||
attr_accessor :username
|
attr_accessor :username
|
||||||
|
|
||||||
attr_accessor :single_ref_type
|
attr_accessor :single_ref_type
|
||||||
@@ -157,61 +157,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -228,24 +173,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class Animal
|
class Animal < ApiModelBase
|
||||||
attr_accessor :class_name
|
attr_accessor :class_name
|
||||||
|
|
||||||
attr_accessor :color
|
attr_accessor :color
|
||||||
@@ -159,61 +159,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -230,24 +175,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class ApiResponse
|
class ApiResponse < ApiModelBase
|
||||||
attr_accessor :code
|
attr_accessor :code
|
||||||
|
|
||||||
attr_accessor :type
|
attr_accessor :type
|
||||||
@@ -144,61 +144,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -215,24 +160,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class ArrayOfArrayOfNumberOnly
|
class ArrayOfArrayOfNumberOnly < ApiModelBase
|
||||||
attr_accessor :array_array_number
|
attr_accessor :array_array_number
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -128,61 +128,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -199,24 +144,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class ArrayOfNumberOnly
|
class ArrayOfNumberOnly < ApiModelBase
|
||||||
attr_accessor :array_number
|
attr_accessor :array_number
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -128,61 +128,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -199,24 +144,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class ArrayTest
|
class ArrayTest < ApiModelBase
|
||||||
attr_accessor :array_of_string
|
attr_accessor :array_of_string
|
||||||
|
|
||||||
attr_accessor :array_array_of_integer
|
attr_accessor :array_array_of_integer
|
||||||
@@ -178,61 +178,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -249,24 +194,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class Capitalization
|
class Capitalization < ApiModelBase
|
||||||
attr_accessor :small_camel
|
attr_accessor :small_camel
|
||||||
|
|
||||||
attr_accessor :capital_camel
|
attr_accessor :capital_camel
|
||||||
@@ -172,61 +172,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -243,24 +188,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -137,61 +137,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -208,24 +153,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class Category
|
class Category < ApiModelBase
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
@@ -152,61 +152,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -223,24 +168,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -159,61 +159,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -230,24 +175,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ require 'time'
|
|||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
# Model for testing model with \"_class\" property
|
# Model for testing model with \"_class\" property
|
||||||
class ClassModel
|
class ClassModel < ApiModelBase
|
||||||
attr_accessor :_class
|
attr_accessor :_class
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -127,61 +127,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -198,24 +143,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class Client
|
class Client < ApiModelBase
|
||||||
attr_accessor :client
|
attr_accessor :client
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -126,61 +126,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -197,24 +142,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class DeprecatedObject
|
class DeprecatedObject < ApiModelBase
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -126,61 +126,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -197,24 +142,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -137,61 +137,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -208,24 +153,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class EnumArrays
|
class EnumArrays < ApiModelBase
|
||||||
attr_accessor :just_symbol
|
attr_accessor :just_symbol
|
||||||
|
|
||||||
attr_accessor :array_enum
|
attr_accessor :array_enum
|
||||||
@@ -171,61 +171,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -242,24 +187,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class EnumTest
|
class EnumTest < ApiModelBase
|
||||||
attr_accessor :enum_string
|
attr_accessor :enum_string
|
||||||
|
|
||||||
attr_accessor :enum_string_required
|
attr_accessor :enum_string_required
|
||||||
@@ -271,61 +271,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -342,24 +287,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class FakeBigDecimalMap200Response
|
class FakeBigDecimalMap200Response < ApiModelBase
|
||||||
attr_accessor :some_id
|
attr_accessor :some_id
|
||||||
|
|
||||||
attr_accessor :some_map
|
attr_accessor :some_map
|
||||||
@@ -137,61 +137,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -208,24 +153,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ require 'time'
|
|||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
# Must be named `File` for test.
|
# Must be named `File` for test.
|
||||||
class File
|
class File < ApiModelBase
|
||||||
# Test capitalization
|
# Test capitalization
|
||||||
attr_accessor :source_uri
|
attr_accessor :source_uri
|
||||||
|
|
||||||
@@ -128,61 +128,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -199,24 +144,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class FileSchemaTestClass
|
class FileSchemaTestClass < ApiModelBase
|
||||||
attr_accessor :file
|
attr_accessor :file
|
||||||
|
|
||||||
attr_accessor :files
|
attr_accessor :files
|
||||||
@@ -137,61 +137,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -208,24 +153,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class Foo
|
class Foo < ApiModelBase
|
||||||
attr_accessor :bar
|
attr_accessor :bar
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -128,61 +128,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -199,24 +144,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class FooGetDefaultResponse
|
class FooGetDefaultResponse < ApiModelBase
|
||||||
attr_accessor :string
|
attr_accessor :string
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -126,61 +126,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -197,24 +142,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class FormatTest
|
class FormatTest < ApiModelBase
|
||||||
attr_accessor :integer
|
attr_accessor :integer
|
||||||
|
|
||||||
attr_accessor :int32
|
attr_accessor :int32
|
||||||
@@ -542,61 +542,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -613,24 +558,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class HasOnlyReadOnly
|
class HasOnlyReadOnly < ApiModelBase
|
||||||
attr_accessor :bar
|
attr_accessor :bar
|
||||||
|
|
||||||
attr_accessor :foo
|
attr_accessor :foo
|
||||||
@@ -135,61 +135,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -206,24 +151,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ require 'time'
|
|||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
# Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model.
|
# Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model.
|
||||||
class HealthCheckResult
|
class HealthCheckResult < ApiModelBase
|
||||||
attr_accessor :nullable_message
|
attr_accessor :nullable_message
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -128,61 +128,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -199,24 +144,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class List
|
class List < ApiModelBase
|
||||||
attr_accessor :_123_list
|
attr_accessor :_123_list
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -126,61 +126,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -197,24 +142,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class MapTest
|
class MapTest < ApiModelBase
|
||||||
attr_accessor :map_map_of_string
|
attr_accessor :map_map_of_string
|
||||||
|
|
||||||
attr_accessor :map_of_enum_string
|
attr_accessor :map_of_enum_string
|
||||||
@@ -183,61 +183,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -254,24 +199,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class MixedPropertiesAndAdditionalPropertiesClass
|
class MixedPropertiesAndAdditionalPropertiesClass < ApiModelBase
|
||||||
attr_accessor :uuid
|
attr_accessor :uuid
|
||||||
|
|
||||||
attr_accessor :date_time
|
attr_accessor :date_time
|
||||||
@@ -146,61 +146,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -217,24 +162,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ require 'time'
|
|||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
# Model for testing model name starting with number
|
# Model for testing model name starting with number
|
||||||
class Model200Response
|
class Model200Response < ApiModelBase
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
|
|
||||||
attr_accessor :_class
|
attr_accessor :_class
|
||||||
@@ -136,61 +136,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -207,24 +152,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ require 'time'
|
|||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
# Model for testing reserved words
|
# Model for testing reserved words
|
||||||
class ModelReturn
|
class ModelReturn < ApiModelBase
|
||||||
attr_accessor :_return
|
attr_accessor :_return
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -127,61 +127,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -198,24 +143,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ require 'time'
|
|||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
# Model for testing model name same as property name
|
# Model for testing model name same as property name
|
||||||
class Name
|
class Name < ApiModelBase
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
|
|
||||||
attr_accessor :snake_case
|
attr_accessor :snake_case
|
||||||
@@ -171,61 +171,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -242,24 +187,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class NullableClass
|
class NullableClass < ApiModelBase
|
||||||
attr_accessor :integer_prop
|
attr_accessor :integer_prop
|
||||||
|
|
||||||
attr_accessor :number_prop
|
attr_accessor :number_prop
|
||||||
@@ -247,61 +247,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -318,24 +263,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class NumberOnly
|
class NumberOnly < ApiModelBase
|
||||||
attr_accessor :just_number
|
attr_accessor :just_number
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -126,61 +126,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -197,24 +142,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class ObjectWithDeprecatedFields
|
class ObjectWithDeprecatedFields < ApiModelBase
|
||||||
attr_accessor :uuid
|
attr_accessor :uuid
|
||||||
|
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
@@ -155,61 +155,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -226,24 +171,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class Order
|
class Order < ApiModelBase
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
attr_accessor :pet_id
|
attr_accessor :pet_id
|
||||||
@@ -208,61 +208,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -279,24 +224,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class OuterComposite
|
class OuterComposite < ApiModelBase
|
||||||
attr_accessor :my_number
|
attr_accessor :my_number
|
||||||
|
|
||||||
attr_accessor :my_string
|
attr_accessor :my_string
|
||||||
@@ -144,61 +144,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -215,24 +160,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class OuterObjectWithEnumProperty
|
class OuterObjectWithEnumProperty < ApiModelBase
|
||||||
attr_accessor :value
|
attr_accessor :value
|
||||||
|
|
||||||
class EnumAttributeValidator
|
class EnumAttributeValidator
|
||||||
@@ -165,61 +165,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -236,24 +181,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class ParentWithNullable
|
class ParentWithNullable < ApiModelBase
|
||||||
attr_accessor :type
|
attr_accessor :type
|
||||||
|
|
||||||
attr_accessor :nullable_property
|
attr_accessor :nullable_property
|
||||||
@@ -175,61 +175,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -246,24 +191,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class Pet
|
class Pet < ApiModelBase
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
attr_accessor :category
|
attr_accessor :category
|
||||||
@@ -244,61 +244,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -315,24 +260,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class ReadOnlyFirst
|
class ReadOnlyFirst < ApiModelBase
|
||||||
attr_accessor :bar
|
attr_accessor :bar
|
||||||
|
|
||||||
attr_accessor :baz
|
attr_accessor :baz
|
||||||
@@ -135,61 +135,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -206,24 +151,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class SpecialModelName
|
class SpecialModelName < ApiModelBase
|
||||||
attr_accessor :special_property_name
|
attr_accessor :special_property_name
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -126,61 +126,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -197,24 +142,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class Tag
|
class Tag < ApiModelBase
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
@@ -135,61 +135,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -206,24 +151,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class TestInlineFreeformAdditionalPropertiesRequest
|
class TestInlineFreeformAdditionalPropertiesRequest < ApiModelBase
|
||||||
attr_accessor :some_property
|
attr_accessor :some_property
|
||||||
|
|
||||||
# Attribute mapping from ruby-style variable name to JSON key.
|
# Attribute mapping from ruby-style variable name to JSON key.
|
||||||
@@ -126,61 +126,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -197,24 +142,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class User
|
class User < ApiModelBase
|
||||||
attr_accessor :id
|
attr_accessor :id
|
||||||
|
|
||||||
attr_accessor :username
|
attr_accessor :username
|
||||||
@@ -190,61 +190,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -261,24 +206,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ lib/petstore/api/store_api.rb
|
|||||||
lib/petstore/api/user_api.rb
|
lib/petstore/api/user_api.rb
|
||||||
lib/petstore/api_client.rb
|
lib/petstore/api_client.rb
|
||||||
lib/petstore/api_error.rb
|
lib/petstore/api_error.rb
|
||||||
|
lib/petstore/api_model_base.rb
|
||||||
lib/petstore/configuration.rb
|
lib/petstore/configuration.rb
|
||||||
lib/petstore/models/additional_properties_class.rb
|
lib/petstore/models/additional_properties_class.rb
|
||||||
lib/petstore/models/all_of_with_single_ref.rb
|
lib/petstore/models/all_of_with_single_ref.rb
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ Generator version: 7.17.0-SNAPSHOT
|
|||||||
# Common files
|
# Common files
|
||||||
require 'petstore/api_client'
|
require 'petstore/api_client'
|
||||||
require 'petstore/api_error'
|
require 'petstore/api_error'
|
||||||
|
require 'petstore/api_model_base'
|
||||||
require 'petstore/version'
|
require 'petstore/version'
|
||||||
require 'petstore/configuration'
|
require 'petstore/configuration'
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
=begin
|
||||||
|
#OpenAPI Petstore
|
||||||
|
|
||||||
|
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
|
||||||
|
Generated by: https://openapi-generator.tech
|
||||||
|
Generator version: 7.17.0-SNAPSHOT
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
module Petstore
|
||||||
|
class ApiModelBase
|
||||||
|
# Deserializes the data based on type
|
||||||
|
# @param string type Data type
|
||||||
|
# @param string value Value to be deserialized
|
||||||
|
# @return [Object] Deserialized data
|
||||||
|
def self._deserialize(type, value)
|
||||||
|
case type.to_sym
|
||||||
|
when :Time
|
||||||
|
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
||||||
|
# models (e.g. Pet) or oneOf
|
||||||
|
klass = Petstore.const_get(type)
|
||||||
|
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
||||||
|
# @return [Hash] Returns the object in the form of hash
|
||||||
|
def to_body
|
||||||
|
to_hash
|
||||||
|
end
|
||||||
|
|
||||||
|
# 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) }
|
||||||
|
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
|
||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class AdditionalPropertiesClass
|
class AdditionalPropertiesClass < ApiModelBase
|
||||||
attr_accessor :map_property
|
attr_accessor :map_property
|
||||||
|
|
||||||
attr_accessor :map_of_map_property
|
attr_accessor :map_of_map_property
|
||||||
@@ -139,61 +139,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -210,24 +155,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class AllOfWithSingleRef
|
class AllOfWithSingleRef < ApiModelBase
|
||||||
attr_accessor :username
|
attr_accessor :username
|
||||||
|
|
||||||
attr_accessor :single_ref_type
|
attr_accessor :single_ref_type
|
||||||
@@ -157,61 +157,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -228,24 +173,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ require 'date'
|
|||||||
require 'time'
|
require 'time'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
class Animal
|
class Animal < ApiModelBase
|
||||||
attr_accessor :class_name
|
attr_accessor :class_name
|
||||||
|
|
||||||
attr_accessor :color
|
attr_accessor :color
|
||||||
@@ -159,61 +159,6 @@ module Petstore
|
|||||||
new(transformed_hash)
|
new(transformed_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deserializes the data based on type
|
|
||||||
# @param string type Data type
|
|
||||||
# @param string value Value to be deserialized
|
|
||||||
# @return [Object] Deserialized data
|
|
||||||
def self._deserialize(type, value)
|
|
||||||
case type.to_sym
|
|
||||||
when :Time
|
|
||||||
Time.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 =~ /\A(true|t|yes|y|1)\z/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
|
|
||||||
# models (e.g. Pet) or oneOf
|
|
||||||
klass = Petstore.const_get(type)
|
|
||||||
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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_hash (backward compatibility)
|
|
||||||
# @return [Hash] Returns the object in the form of hash
|
|
||||||
def to_body
|
|
||||||
to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns 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
|
# @return [Hash] Returns the object in the form of hash
|
||||||
def to_hash
|
def to_hash
|
||||||
@@ -230,24 +175,6 @@ module Petstore
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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) }
|
|
||||||
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user