Merge remote-tracking branch 'origin/4.1.x' into sync_41x_50x

This commit is contained in:
wing328
2019-06-27 18:27:20 +08:00
1243 changed files with 38715 additions and 15082 deletions

View File

@@ -46,7 +46,7 @@ Layout/EmptyLinesAroundMethodBody:
Layout/EmptyLinesAroundModuleBody:
Enabled: true
Layout/FirstParameterIndentation:
Layout/IndentFirstArgument:
Enabled: true
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.

View File

@@ -139,6 +139,12 @@ Class | Method | HTTP request | Description
- [Petstore::FormatTest](docs/FormatTest.md)
- [Petstore::HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
- [Petstore::HealthCheckResult](docs/HealthCheckResult.md)
- [Petstore::InlineObject](docs/InlineObject.md)
- [Petstore::InlineObject1](docs/InlineObject1.md)
- [Petstore::InlineObject2](docs/InlineObject2.md)
- [Petstore::InlineObject3](docs/InlineObject3.md)
- [Petstore::InlineObject4](docs/InlineObject4.md)
- [Petstore::InlineObject5](docs/InlineObject5.md)
- [Petstore::InlineResponseDefault](docs/InlineResponseDefault.md)
- [Petstore::List](docs/List.md)
- [Petstore::MapTest](docs/MapTest.md)

View File

@@ -0,0 +1,19 @@
# Petstore::InlineObject
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **String** | Updated name of the pet | [optional]
**status** | **String** | Updated status of the pet | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::InlineObject.new(name: null,
status: null)
```

View File

@@ -0,0 +1,19 @@
# Petstore::InlineObject1
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**additional_metadata** | **String** | Additional data to pass to server | [optional]
**file** | **File** | file to upload | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::InlineObject1.new(additional_metadata: null,
file: null)
```

View File

@@ -0,0 +1,19 @@
# Petstore::InlineObject2
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**enum_form_string_array** | **Array<String>** | Form parameter enum test (string array) | [optional]
**enum_form_string** | **String** | Form parameter enum test (string) | [optional] [default to '-efg']
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::InlineObject2.new(enum_form_string_array: null,
enum_form_string: null)
```

View File

@@ -0,0 +1,43 @@
# Petstore::InlineObject3
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**integer** | **Integer** | None | [optional]
**int32** | **Integer** | None | [optional]
**int64** | **Integer** | None | [optional]
**number** | **Float** | None |
**float** | **Float** | None | [optional]
**double** | **Float** | None |
**string** | **String** | None | [optional]
**pattern_without_delimiter** | **String** | None |
**byte** | **String** | None |
**binary** | **File** | None | [optional]
**date** | **Date** | None | [optional]
**date_time** | **DateTime** | None | [optional]
**password** | **String** | None | [optional]
**callback** | **String** | None | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::InlineObject3.new(integer: null,
int32: null,
int64: null,
number: null,
float: null,
double: null,
string: null,
pattern_without_delimiter: null,
byte: null,
binary: null,
date: null,
date_time: null,
password: null,
callback: null)
```

View File

@@ -0,0 +1,19 @@
# Petstore::InlineObject4
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**param** | **String** | field1 |
**param2** | **String** | field2 |
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::InlineObject4.new(param: null,
param2: null)
```

View File

@@ -0,0 +1,19 @@
# Petstore::InlineObject5
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**additional_metadata** | **String** | Additional data to pass to server | [optional]
**required_file** | **File** | file to upload |
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::InlineObject5.new(additional_metadata: null,
required_file: null)
```

View File

@@ -74,7 +74,7 @@ Creates list of users with given input array
require 'petstore'
api_instance = Petstore::UserApi.new
user = nil # Array<User> | List of user object
user = [Petstore::User.new] # Array<User> | List of user object
begin
#Creates list of users with given input array
@@ -89,7 +89,7 @@ end
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**Array&lt;User&gt;**](Array.md)| List of user object |
**user** | [**Array&lt;User&gt;**](User.md)| List of user object |
### Return type
@@ -118,7 +118,7 @@ Creates list of users with given input array
require 'petstore'
api_instance = Petstore::UserApi.new
user = nil # Array<User> | List of user object
user = [Petstore::User.new] # Array<User> | List of user object
begin
#Creates list of users with given input array
@@ -133,7 +133,7 @@ end
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**Array&lt;User&gt;**](Array.md)| List of user object |
**user** | [**Array&lt;User&gt;**](User.md)| List of user object |
### Return type

View File

@@ -40,6 +40,12 @@ require 'petstore/models/foo'
require 'petstore/models/format_test'
require 'petstore/models/has_only_read_only'
require 'petstore/models/health_check_result'
require 'petstore/models/inline_object'
require 'petstore/models/inline_object1'
require 'petstore/models/inline_object2'
require 'petstore/models/inline_object3'
require 'petstore/models/inline_object4'
require 'petstore/models/inline_object5'
require 'petstore/models/inline_response_default'
require 'petstore/models/list'
require 'petstore/models/map_test'

View File

@@ -10,7 +10,6 @@ OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'uri'
require 'cgi'
module Petstore

View File

@@ -10,7 +10,6 @@ OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'uri'
require 'cgi'
module Petstore

View File

@@ -10,7 +10,6 @@ OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'uri'
require 'cgi'
module Petstore

View File

@@ -10,7 +10,6 @@ OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'uri'
require 'cgi'
module Petstore

View File

@@ -10,7 +10,6 @@ OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'uri'
require 'cgi'
module Petstore
@@ -104,7 +103,7 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
# query parameters
query_params = opts[:query_params] || {}
@@ -291,7 +290,7 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.get_pet_by_id"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
# query parameters
query_params = opts[:query_params] || {}
@@ -415,7 +414,7 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.update_pet_with_form"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
# query parameters
query_params = opts[:query_params] || {}
@@ -481,7 +480,7 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.upload_file"
end
# resource path
local_var_path = '/pet/{petId}/uploadImage'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))
local_var_path = '/pet/{petId}/uploadImage'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
# query parameters
query_params = opts[:query_params] || {}
@@ -553,7 +552,7 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'required_file' when calling PetApi.upload_file_with_required_file"
end
# resource path
local_var_path = '/fake/{petId}/uploadImageWithRequiredFile'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))
local_var_path = '/fake/{petId}/uploadImageWithRequiredFile'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
# query parameters
query_params = opts[:query_params] || {}

View File

@@ -10,7 +10,6 @@ OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'uri'
require 'cgi'
module Petstore
@@ -44,7 +43,7 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.delete_order"
end
# resource path
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s))
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s).gsub('%2F', '/'))
# query parameters
query_params = opts[:query_params] || {}
@@ -168,7 +167,7 @@ module Petstore
end
# resource path
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s))
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s).gsub('%2F', '/'))
# query parameters
query_params = opts[:query_params] || {}

View File

@@ -10,7 +10,6 @@ OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'uri'
require 'cgi'
module Petstore
@@ -226,7 +225,7 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.delete_user"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s).gsub('%2F', '/'))
# query parameters
query_params = opts[:query_params] || {}
@@ -284,7 +283,7 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.get_user_by_name"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s).gsub('%2F', '/'))
# query parameters
query_params = opts[:query_params] || {}
@@ -472,7 +471,7 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'user' when calling UserApi.update_user"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s).gsub('%2F', '/'))
# query parameters
query_params = opts[:query_params] || {}

View File

@@ -15,7 +15,6 @@ require 'json'
require 'logger'
require 'tempfile'
require 'typhoeus'
require 'uri'
module Petstore
class ApiClient
@@ -262,7 +261,7 @@ module Petstore
def build_request_url(path)
# Add leading and trailing slashes to path
path = "/#{path}".gsub(/\/+/, '/')
URI.encode(@config.base_url + path)
@config.base_url + path
end
# Builds the HTTP request body

View File

@@ -10,8 +10,6 @@ OpenAPI Generator version: 5.0.0-SNAPSHOT
=end
require 'uri'
module Petstore
class Configuration
# Defines url scheme
@@ -174,8 +172,7 @@ module Petstore
end
def base_url
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
URI.encode(url)
"#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
end
# Gets API key (with prefix if set).

View File

@@ -0,0 +1,207 @@
=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
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'date'
module Petstore
class InlineObject
# Updated name of the pet
attr_accessor :name
# Updated status of the pet
attr_accessor :status
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'name' => :'name',
:'status' => :'status'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'name' => :'String',
:'status' => :'String'
}
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'status')
self.status = attributes[:'status']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
name == o.name &&
status == o.status
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[name, status].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.openapi_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\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
Petstore.const_get(type).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
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end
# 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

View File

@@ -0,0 +1,207 @@
=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
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'date'
module Petstore
class InlineObject1
# Additional data to pass to server
attr_accessor :additional_metadata
# file to upload
attr_accessor :file
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'additional_metadata' => :'additionalMetadata',
:'file' => :'file'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'additional_metadata' => :'String',
:'file' => :'File'
}
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject1` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject1`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'additional_metadata')
self.additional_metadata = attributes[:'additional_metadata']
end
if attributes.key?(:'file')
self.file = attributes[:'file']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
additional_metadata == o.additional_metadata &&
file == o.file
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[additional_metadata, file].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.openapi_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\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
Petstore.const_get(type).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
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end
# 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

View File

@@ -0,0 +1,245 @@
=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
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'date'
module Petstore
class InlineObject2
# Form parameter enum test (string array)
attr_accessor :enum_form_string_array
# Form parameter enum test (string)
attr_accessor :enum_form_string
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end
def valid?(value)
!value || allowable_values.include?(value)
end
end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'enum_form_string_array' => :'enum_form_string_array',
:'enum_form_string' => :'enum_form_string'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'enum_form_string_array' => :'Array<String>',
:'enum_form_string' => :'String'
}
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject2` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject2`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'enum_form_string_array')
if (value = attributes[:'enum_form_string_array']).is_a?(Array)
self.enum_form_string_array = value
end
end
if attributes.key?(:'enum_form_string')
self.enum_form_string = attributes[:'enum_form_string']
else
self.enum_form_string = '-efg'
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
enum_form_string_validator = EnumAttributeValidator.new('String', ["_abc", "-efg", "(xyz)"])
return false unless enum_form_string_validator.valid?(@enum_form_string)
true
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] enum_form_string Object to be assigned
def enum_form_string=(enum_form_string)
validator = EnumAttributeValidator.new('String', ["_abc", "-efg", "(xyz)"])
unless validator.valid?(enum_form_string)
fail ArgumentError, "invalid value for \"enum_form_string\", must be one of #{validator.allowable_values}."
end
@enum_form_string = enum_form_string
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
enum_form_string_array == o.enum_form_string_array &&
enum_form_string == o.enum_form_string
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[enum_form_string_array, enum_form_string].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.openapi_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\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
Petstore.const_get(type).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
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end
# 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

View File

@@ -0,0 +1,528 @@
=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
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'date'
module Petstore
class InlineObject3
# None
attr_accessor :integer
# None
attr_accessor :int32
# None
attr_accessor :int64
# None
attr_accessor :number
# None
attr_accessor :float
# None
attr_accessor :double
# None
attr_accessor :string
# None
attr_accessor :pattern_without_delimiter
# None
attr_accessor :byte
# None
attr_accessor :binary
# None
attr_accessor :date
# None
attr_accessor :date_time
# None
attr_accessor :password
# None
attr_accessor :callback
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'integer' => :'integer',
:'int32' => :'int32',
:'int64' => :'int64',
:'number' => :'number',
:'float' => :'float',
:'double' => :'double',
:'string' => :'string',
:'pattern_without_delimiter' => :'pattern_without_delimiter',
:'byte' => :'byte',
:'binary' => :'binary',
:'date' => :'date',
:'date_time' => :'dateTime',
:'password' => :'password',
:'callback' => :'callback'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'integer' => :'Integer',
:'int32' => :'Integer',
:'int64' => :'Integer',
:'number' => :'Float',
:'float' => :'Float',
:'double' => :'Float',
:'string' => :'String',
:'pattern_without_delimiter' => :'String',
:'byte' => :'String',
:'binary' => :'File',
:'date' => :'Date',
:'date_time' => :'DateTime',
:'password' => :'String',
:'callback' => :'String'
}
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject3` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject3`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'integer')
self.integer = attributes[:'integer']
end
if attributes.key?(:'int32')
self.int32 = attributes[:'int32']
end
if attributes.key?(:'int64')
self.int64 = attributes[:'int64']
end
if attributes.key?(:'number')
self.number = attributes[:'number']
end
if attributes.key?(:'float')
self.float = attributes[:'float']
end
if attributes.key?(:'double')
self.double = attributes[:'double']
end
if attributes.key?(:'string')
self.string = attributes[:'string']
end
if attributes.key?(:'pattern_without_delimiter')
self.pattern_without_delimiter = attributes[:'pattern_without_delimiter']
end
if attributes.key?(:'byte')
self.byte = attributes[:'byte']
end
if attributes.key?(:'binary')
self.binary = attributes[:'binary']
end
if attributes.key?(:'date')
self.date = attributes[:'date']
end
if attributes.key?(:'date_time')
self.date_time = attributes[:'date_time']
end
if attributes.key?(:'password')
self.password = attributes[:'password']
end
if attributes.key?(:'callback')
self.callback = attributes[:'callback']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if !@integer.nil? && @integer > 100
invalid_properties.push('invalid value for "integer", must be smaller than or equal to 100.')
end
if !@integer.nil? && @integer < 10
invalid_properties.push('invalid value for "integer", must be greater than or equal to 10.')
end
if !@int32.nil? && @int32 > 200
invalid_properties.push('invalid value for "int32", must be smaller than or equal to 200.')
end
if !@int32.nil? && @int32 < 20
invalid_properties.push('invalid value for "int32", must be greater than or equal to 20.')
end
if @number.nil?
invalid_properties.push('invalid value for "number", number cannot be nil.')
end
if @number > 543.2
invalid_properties.push('invalid value for "number", must be smaller than or equal to 543.2.')
end
if @number < 32.1
invalid_properties.push('invalid value for "number", must be greater than or equal to 32.1.')
end
if !@float.nil? && @float > 987.6
invalid_properties.push('invalid value for "float", must be smaller than or equal to 987.6.')
end
if @double.nil?
invalid_properties.push('invalid value for "double", double cannot be nil.')
end
if @double > 123.4
invalid_properties.push('invalid value for "double", must be smaller than or equal to 123.4.')
end
if @double < 67.8
invalid_properties.push('invalid value for "double", must be greater than or equal to 67.8.')
end
pattern = Regexp.new(/[a-z]/i)
if !@string.nil? && @string !~ pattern
invalid_properties.push("invalid value for \"string\", must conform to the pattern #{pattern}.")
end
if @pattern_without_delimiter.nil?
invalid_properties.push('invalid value for "pattern_without_delimiter", pattern_without_delimiter cannot be nil.')
end
pattern = Regexp.new(/^[A-Z].*/)
if @pattern_without_delimiter !~ pattern
invalid_properties.push("invalid value for \"pattern_without_delimiter\", must conform to the pattern #{pattern}.")
end
if @byte.nil?
invalid_properties.push('invalid value for "byte", byte cannot be nil.')
end
if !@password.nil? && @password.to_s.length > 64
invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 64.')
end
if !@password.nil? && @password.to_s.length < 10
invalid_properties.push('invalid value for "password", the character length must be great than or equal to 10.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if !@integer.nil? && @integer > 100
return false if !@integer.nil? && @integer < 10
return false if !@int32.nil? && @int32 > 200
return false if !@int32.nil? && @int32 < 20
return false if @number.nil?
return false if @number > 543.2
return false if @number < 32.1
return false if !@float.nil? && @float > 987.6
return false if @double.nil?
return false if @double > 123.4
return false if @double < 67.8
return false if !@string.nil? && @string !~ Regexp.new(/[a-z]/i)
return false if @pattern_without_delimiter.nil?
return false if @pattern_without_delimiter !~ Regexp.new(/^[A-Z].*/)
return false if @byte.nil?
return false if !@password.nil? && @password.to_s.length > 64
return false if !@password.nil? && @password.to_s.length < 10
true
end
# Custom attribute writer method with validation
# @param [Object] integer Value to be assigned
def integer=(integer)
if !integer.nil? && integer > 100
fail ArgumentError, 'invalid value for "integer", must be smaller than or equal to 100.'
end
if !integer.nil? && integer < 10
fail ArgumentError, 'invalid value for "integer", must be greater than or equal to 10.'
end
@integer = integer
end
# Custom attribute writer method with validation
# @param [Object] int32 Value to be assigned
def int32=(int32)
if !int32.nil? && int32 > 200
fail ArgumentError, 'invalid value for "int32", must be smaller than or equal to 200.'
end
if !int32.nil? && int32 < 20
fail ArgumentError, 'invalid value for "int32", must be greater than or equal to 20.'
end
@int32 = int32
end
# Custom attribute writer method with validation
# @param [Object] number Value to be assigned
def number=(number)
if number.nil?
fail ArgumentError, 'number cannot be nil'
end
if number > 543.2
fail ArgumentError, 'invalid value for "number", must be smaller than or equal to 543.2.'
end
if number < 32.1
fail ArgumentError, 'invalid value for "number", must be greater than or equal to 32.1.'
end
@number = number
end
# Custom attribute writer method with validation
# @param [Object] float Value to be assigned
def float=(float)
if !float.nil? && float > 987.6
fail ArgumentError, 'invalid value for "float", must be smaller than or equal to 987.6.'
end
@float = float
end
# Custom attribute writer method with validation
# @param [Object] double Value to be assigned
def double=(double)
if double.nil?
fail ArgumentError, 'double cannot be nil'
end
if double > 123.4
fail ArgumentError, 'invalid value for "double", must be smaller than or equal to 123.4.'
end
if double < 67.8
fail ArgumentError, 'invalid value for "double", must be greater than or equal to 67.8.'
end
@double = double
end
# Custom attribute writer method with validation
# @param [Object] string Value to be assigned
def string=(string)
pattern = Regexp.new(/[a-z]/i)
if !string.nil? && string !~ pattern
fail ArgumentError, "invalid value for \"string\", must conform to the pattern #{pattern}."
end
@string = string
end
# Custom attribute writer method with validation
# @param [Object] pattern_without_delimiter Value to be assigned
def pattern_without_delimiter=(pattern_without_delimiter)
if pattern_without_delimiter.nil?
fail ArgumentError, 'pattern_without_delimiter cannot be nil'
end
pattern = Regexp.new(/^[A-Z].*/)
if pattern_without_delimiter !~ pattern
fail ArgumentError, "invalid value for \"pattern_without_delimiter\", must conform to the pattern #{pattern}."
end
@pattern_without_delimiter = pattern_without_delimiter
end
# Custom attribute writer method with validation
# @param [Object] password Value to be assigned
def password=(password)
if !password.nil? && password.to_s.length > 64
fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 64.'
end
if !password.nil? && password.to_s.length < 10
fail ArgumentError, 'invalid value for "password", the character length must be great than or equal to 10.'
end
@password = password
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
integer == o.integer &&
int32 == o.int32 &&
int64 == o.int64 &&
number == o.number &&
float == o.float &&
double == o.double &&
string == o.string &&
pattern_without_delimiter == o.pattern_without_delimiter &&
byte == o.byte &&
binary == o.binary &&
date == o.date &&
date_time == o.date_time &&
password == o.password &&
callback == o.callback
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[integer, int32, int64, number, float, double, string, pattern_without_delimiter, byte, binary, date, date_time, password, callback].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.openapi_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\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
Petstore.const_get(type).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
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end
# 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

View File

@@ -0,0 +1,217 @@
=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
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'date'
module Petstore
class InlineObject4
# field1
attr_accessor :param
# field2
attr_accessor :param2
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'param' => :'param',
:'param2' => :'param2'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'param' => :'String',
:'param2' => :'String'
}
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject4` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject4`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'param')
self.param = attributes[:'param']
end
if attributes.key?(:'param2')
self.param2 = attributes[:'param2']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @param.nil?
invalid_properties.push('invalid value for "param", param cannot be nil.')
end
if @param2.nil?
invalid_properties.push('invalid value for "param2", param2 cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @param.nil?
return false if @param2.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
param == o.param &&
param2 == o.param2
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[param, param2].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.openapi_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\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
Petstore.const_get(type).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
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end
# 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

View File

@@ -0,0 +1,212 @@
=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
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'date'
module Petstore
class InlineObject5
# Additional data to pass to server
attr_accessor :additional_metadata
# file to upload
attr_accessor :required_file
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'additional_metadata' => :'additionalMetadata',
:'required_file' => :'requiredFile'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'additional_metadata' => :'String',
:'required_file' => :'File'
}
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject5` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject5`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'additional_metadata')
self.additional_metadata = attributes[:'additional_metadata']
end
if attributes.key?(:'required_file')
self.required_file = attributes[:'required_file']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
if @required_file.nil?
invalid_properties.push('invalid value for "required_file", required_file cannot be nil.')
end
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @required_file.nil?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
additional_metadata == o.additional_metadata &&
required_file == o.required_file
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[additional_metadata, required_file].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.openapi_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\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
Petstore.const_get(type).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
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end
# 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

View File

@@ -0,0 +1,47 @@
=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
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for Petstore::InlineObject1
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
describe 'InlineObject1' do
before do
# run before each test
@instance = Petstore::InlineObject1.new
end
after do
# run after each test
end
describe 'test an instance of InlineObject1' do
it 'should create an instance of InlineObject1' do
expect(@instance).to be_instance_of(Petstore::InlineObject1)
end
end
describe 'test attribute "additional_metadata"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "file"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
end

View File

@@ -0,0 +1,55 @@
=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
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for Petstore::InlineObject2
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
describe 'InlineObject2' do
before do
# run before each test
@instance = Petstore::InlineObject2.new
end
after do
# run after each test
end
describe 'test an instance of InlineObject2' do
it 'should create an instance of InlineObject2' do
expect(@instance).to be_instance_of(Petstore::InlineObject2)
end
end
describe 'test attribute "enum_form_string_array"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# validator = Petstore::EnumTest::EnumAttributeValidator.new('Array<String>', [">", "$"])
# validator.allowable_values.each do |value|
# expect { @instance.enum_form_string_array = value }.not_to raise_error
# end
end
end
describe 'test attribute "enum_form_string"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
# validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["_abc", "-efg", "(xyz)"])
# validator.allowable_values.each do |value|
# expect { @instance.enum_form_string = value }.not_to raise_error
# end
end
end
end

View File

@@ -0,0 +1,119 @@
=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
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for Petstore::InlineObject3
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
describe 'InlineObject3' do
before do
# run before each test
@instance = Petstore::InlineObject3.new
end
after do
# run after each test
end
describe 'test an instance of InlineObject3' do
it 'should create an instance of InlineObject3' do
expect(@instance).to be_instance_of(Petstore::InlineObject3)
end
end
describe 'test attribute "integer"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "int32"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "int64"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "number"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "float"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "double"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "string"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "pattern_without_delimiter"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "byte"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "binary"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "date"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "date_time"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "password"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "callback"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
end

View File

@@ -0,0 +1,47 @@
=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
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for Petstore::InlineObject4
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
describe 'InlineObject4' do
before do
# run before each test
@instance = Petstore::InlineObject4.new
end
after do
# run after each test
end
describe 'test an instance of InlineObject4' do
it 'should create an instance of InlineObject4' do
expect(@instance).to be_instance_of(Petstore::InlineObject4)
end
end
describe 'test attribute "param"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "param2"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
end

View File

@@ -0,0 +1,47 @@
=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
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for Petstore::InlineObject5
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
describe 'InlineObject5' do
before do
# run before each test
@instance = Petstore::InlineObject5.new
end
after do
# run after each test
end
describe 'test an instance of InlineObject5' do
it 'should create an instance of InlineObject5' do
expect(@instance).to be_instance_of(Petstore::InlineObject5)
end
end
describe 'test attribute "additional_metadata"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "required_file"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
end

View File

@@ -0,0 +1,47 @@
=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
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'spec_helper'
require 'json'
require 'date'
# Unit tests for Petstore::InlineObject
# Automatically generated by openapi-generator (https://openapi-generator.tech)
# Please update as you see appropriate
describe 'InlineObject' do
before do
# run before each test
@instance = Petstore::InlineObject.new
end
after do
# run after each test
end
describe 'test an instance of InlineObject' do
it 'should create an instance of InlineObject' do
expect(@instance).to be_instance_of(Petstore::InlineObject)
end
end
describe 'test attribute "name"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
describe 'test attribute "status"' do
it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end
end
end