diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java index 96c459377ed..c0e00177ec0 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java @@ -226,6 +226,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen { supportingFiles.add(new SupportingFile("Gemfile.mustache", "", "Gemfile")); supportingFiles.add(new SupportingFile("Gemfile.lock.mustache", "", "Gemfile.lock")); supportingFiles.add(new SupportingFile("rubocop.mustache", "", ".rubocop.yml")); + supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml")); // test files should not be overwritten writeOptional(outputFolder, new SupportingFile("rspec.mustache", "", ".rspec")); diff --git a/modules/openapi-generator/src/main/resources/ruby-client/api_error.mustache b/modules/openapi-generator/src/main/resources/ruby-client/api_error.mustache index b3320779b36..6d1967b7ba4 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/api_error.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/api_error.mustache @@ -26,5 +26,24 @@ module {{moduleName}} super arg end end + + # Override to_s to display a friendly error message + def to_s + message + end + + def message + if @message.nil? + msg = "Error message: the server returns an error" + else + msg = @message + end + + msg += "\nHTTP status code: #{code}" if code + msg += "\nResponse headers: #{response_headers}" if response_headers + msg += "\nResponse body: #{response_body}" if response_body + + msg + end end end diff --git a/modules/openapi-generator/src/main/resources/ruby-client/api_test.mustache b/modules/openapi-generator/src/main/resources/ruby-client/api_test.mustache index ee3c6e18b55..84d72edbc9f 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/api_test.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/api_test.mustache @@ -11,7 +11,7 @@ require 'json' {{#operations}}describe '{{classname}}' do before do # run before each test - @instance = {{moduleName}}::{{classname}}.new + @api_instance = {{moduleName}}::{{classname}}.new end after do @@ -20,7 +20,7 @@ require 'json' describe 'test an instance of {{classname}}' do it 'should create an instance of {{classname}}' do - expect(@instance).to be_instance_of({{moduleName}}::{{classname}}) + expect(@api_instance).to be_instance_of({{moduleName}}::{{classname}}) end end diff --git a/modules/openapi-generator/src/main/resources/ruby-client/model_doc.mustache b/modules/openapi-generator/src/main/resources/ruby-client/model_doc.mustache index 68de5593f65..ec7ebfbf02e 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/model_doc.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/model_doc.mustache @@ -6,4 +6,13 @@ Name | Type | Description | Notes {{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} {{/vars}} +## Code Sample + +```ruby +require '{{moduleName}}' + +instance = {{moduleName}}::{{classname}}.new({{#vars}}{{name}}: {{example}}{{^-last}}, + {{/-last}}{{/vars}}) +``` + {{/model}}{{/models}} diff --git a/modules/openapi-generator/src/main/resources/ruby-client/partial_model_generic.mustache b/modules/openapi-generator/src/main/resources/ruby-client/partial_model_generic.mustache index b2bc8b5660e..64695edf573 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/partial_model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/partial_model_generic.mustache @@ -102,10 +102,17 @@ # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `{{{moduleName}}}::{{{classname}}}` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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 `{{{moduleName}}}::{{{classname}}}`. 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 + } {{#parent}} # call parent's initialize @@ -113,19 +120,19 @@ {{/parent}} {{#vars}} - if attributes.has_key?(:'{{{baseName}}}') + if attributes.key?(:'{{{name}}}') {{#isListContainer}} - if (value = attributes[:'{{{baseName}}}']).is_a?(Array) + if (value = attributes[:'{{{name}}}']).is_a?(Array) self.{{{name}}} = value end {{/isListContainer}} {{#isMapContainer}} - if (value = attributes[:'{{{baseName}}}']).is_a?(Hash) + if (value = attributes[:'{{{name}}}']).is_a?(Hash) self.{{{name}}} = value end {{/isMapContainer}} {{^isContainer}} - self.{{{name}}} = attributes[:'{{{baseName}}}'] + self.{{{name}}} = attributes[:'{{{name}}}'] {{/isContainer}} {{#defaultValue}} else diff --git a/modules/openapi-generator/src/main/resources/ruby-client/travis.mustache b/modules/openapi-generator/src/main/resources/ruby-client/travis.mustache new file mode 100644 index 00000000000..7a5a32b4544 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/ruby-client/travis.mustache @@ -0,0 +1,11 @@ +language: ruby +cache: bundler +rvm: + - 2.3 + - 2.4 + - 2.5 +script: + - bundle install --path vendor/bundle + - bundle exec rspec + - gem build {{{gemName}}}.gemspec + - gem install ./{{{gemName}}}-{{{gemVersion}}}.gem diff --git a/samples/client/petstore/ruby/.travis.yml b/samples/client/petstore/ruby/.travis.yml new file mode 100644 index 00000000000..d2d526df594 --- /dev/null +++ b/samples/client/petstore/ruby/.travis.yml @@ -0,0 +1,11 @@ +language: ruby +cache: bundler +rvm: + - 2.3 + - 2.4 + - 2.5 +script: + - bundle install --path vendor/bundle + - bundle exec rspec + - gem build petstore.gemspec + - gem install ./petstore-1.0.0.gem diff --git a/samples/client/petstore/ruby/docs/AdditionalPropertiesClass.md b/samples/client/petstore/ruby/docs/AdditionalPropertiesClass.md index c3ee2cdf637..6e518a5e4ca 100644 --- a/samples/client/petstore/ruby/docs/AdditionalPropertiesClass.md +++ b/samples/client/petstore/ruby/docs/AdditionalPropertiesClass.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **map_property** | **Hash<String, String>** | | [optional] **map_of_map_property** | **Hash<String, Hash<String, String>>** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::AdditionalPropertiesClass.new(map_property: null, + map_of_map_property: null) +``` + diff --git a/samples/client/petstore/ruby/docs/Animal.md b/samples/client/petstore/ruby/docs/Animal.md index 077e6c2d87c..03edcf2fca9 100644 --- a/samples/client/petstore/ruby/docs/Animal.md +++ b/samples/client/petstore/ruby/docs/Animal.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **class_name** | **String** | | **color** | **String** | | [optional] [default to 'red'] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Animal.new(class_name: null, + color: null) +``` + diff --git a/samples/client/petstore/ruby/docs/ApiResponse.md b/samples/client/petstore/ruby/docs/ApiResponse.md index 843f9cc525b..747ebff5559 100644 --- a/samples/client/petstore/ruby/docs/ApiResponse.md +++ b/samples/client/petstore/ruby/docs/ApiResponse.md @@ -7,4 +7,14 @@ Name | Type | Description | Notes **type** | **String** | | [optional] **message** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::ApiResponse.new(code: null, + type: null, + message: null) +``` + diff --git a/samples/client/petstore/ruby/docs/ArrayOfArrayOfNumberOnly.md b/samples/client/petstore/ruby/docs/ArrayOfArrayOfNumberOnly.md index 003cf9a8d6d..c7af572b3de 100644 --- a/samples/client/petstore/ruby/docs/ArrayOfArrayOfNumberOnly.md +++ b/samples/client/petstore/ruby/docs/ArrayOfArrayOfNumberOnly.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **array_array_number** | **Array<Array<Float>>** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::ArrayOfArrayOfNumberOnly.new(array_array_number: null) +``` + diff --git a/samples/client/petstore/ruby/docs/ArrayOfNumberOnly.md b/samples/client/petstore/ruby/docs/ArrayOfNumberOnly.md index c2b9fada4f8..b2ffb7f78ef 100644 --- a/samples/client/petstore/ruby/docs/ArrayOfNumberOnly.md +++ b/samples/client/petstore/ruby/docs/ArrayOfNumberOnly.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **array_number** | **Array<Float>** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::ArrayOfNumberOnly.new(array_number: null) +``` + diff --git a/samples/client/petstore/ruby/docs/ArrayTest.md b/samples/client/petstore/ruby/docs/ArrayTest.md index 5fbfd67159b..f84b9c549b1 100644 --- a/samples/client/petstore/ruby/docs/ArrayTest.md +++ b/samples/client/petstore/ruby/docs/ArrayTest.md @@ -7,4 +7,14 @@ Name | Type | Description | Notes **array_array_of_integer** | **Array<Array<Integer>>** | | [optional] **array_array_of_model** | **Array<Array<ReadOnlyFirst>>** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::ArrayTest.new(array_of_string: null, + array_array_of_integer: null, + array_array_of_model: null) +``` + diff --git a/samples/client/petstore/ruby/docs/Capitalization.md b/samples/client/petstore/ruby/docs/Capitalization.md index d99c603f54a..18f0a7bf9a2 100644 --- a/samples/client/petstore/ruby/docs/Capitalization.md +++ b/samples/client/petstore/ruby/docs/Capitalization.md @@ -10,4 +10,17 @@ Name | Type | Description | Notes **sca_eth_flow_points** | **String** | | [optional] **att_name** | **String** | Name of the pet | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Capitalization.new(small_camel: null, + capital_camel: null, + small_snake: null, + capital_snake: null, + sca_eth_flow_points: null, + att_name: null) +``` + diff --git a/samples/client/petstore/ruby/docs/Cat.md b/samples/client/petstore/ruby/docs/Cat.md index 6abb9e1a348..5b008c6d831 100644 --- a/samples/client/petstore/ruby/docs/Cat.md +++ b/samples/client/petstore/ruby/docs/Cat.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **declawed** | **BOOLEAN** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Cat.new(declawed: null) +``` + diff --git a/samples/client/petstore/ruby/docs/Category.md b/samples/client/petstore/ruby/docs/Category.md index 4500de105b2..d785404ed10 100644 --- a/samples/client/petstore/ruby/docs/Category.md +++ b/samples/client/petstore/ruby/docs/Category.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **id** | **Integer** | | [optional] **name** | **String** | | [default to 'default-name'] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Category.new(id: null, + name: null) +``` + diff --git a/samples/client/petstore/ruby/docs/ClassModel.md b/samples/client/petstore/ruby/docs/ClassModel.md index cd4de850633..82243bd4f30 100644 --- a/samples/client/petstore/ruby/docs/ClassModel.md +++ b/samples/client/petstore/ruby/docs/ClassModel.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **_class** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::ClassModel.new(_class: null) +``` + diff --git a/samples/client/petstore/ruby/docs/Client.md b/samples/client/petstore/ruby/docs/Client.md index 2b8e400aaee..639e19ad845 100644 --- a/samples/client/petstore/ruby/docs/Client.md +++ b/samples/client/petstore/ruby/docs/Client.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **client** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Client.new(client: null) +``` + diff --git a/samples/client/petstore/ruby/docs/Dog.md b/samples/client/petstore/ruby/docs/Dog.md index 2b8d2281a12..0164e509045 100644 --- a/samples/client/petstore/ruby/docs/Dog.md +++ b/samples/client/petstore/ruby/docs/Dog.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **breed** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Dog.new(breed: null) +``` + diff --git a/samples/client/petstore/ruby/docs/EnumArrays.md b/samples/client/petstore/ruby/docs/EnumArrays.md index ef6a935fbd7..a1de1ae2dba 100644 --- a/samples/client/petstore/ruby/docs/EnumArrays.md +++ b/samples/client/petstore/ruby/docs/EnumArrays.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **just_symbol** | **String** | | [optional] **array_enum** | **Array<String>** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::EnumArrays.new(just_symbol: null, + array_enum: null) +``` + diff --git a/samples/client/petstore/ruby/docs/EnumClass.md b/samples/client/petstore/ruby/docs/EnumClass.md index 8d56e1f8873..0b71f09733e 100644 --- a/samples/client/petstore/ruby/docs/EnumClass.md +++ b/samples/client/petstore/ruby/docs/EnumClass.md @@ -4,4 +4,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::EnumClass.new() +``` + diff --git a/samples/client/petstore/ruby/docs/EnumTest.md b/samples/client/petstore/ruby/docs/EnumTest.md index 87297ac476e..d6025032df4 100644 --- a/samples/client/petstore/ruby/docs/EnumTest.md +++ b/samples/client/petstore/ruby/docs/EnumTest.md @@ -9,4 +9,16 @@ Name | Type | Description | Notes **enum_number** | **Float** | | [optional] **outer_enum** | [**OuterEnum**](OuterEnum.md) | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::EnumTest.new(enum_string: null, + enum_string_required: null, + enum_integer: null, + enum_number: null, + outer_enum: null) +``` + diff --git a/samples/client/petstore/ruby/docs/File.md b/samples/client/petstore/ruby/docs/File.md index 428a5a04188..2f2b8aaf748 100644 --- a/samples/client/petstore/ruby/docs/File.md +++ b/samples/client/petstore/ruby/docs/File.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **source_uri** | **String** | Test capitalization | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::File.new(source_uri: null) +``` + diff --git a/samples/client/petstore/ruby/docs/FileSchemaTestClass.md b/samples/client/petstore/ruby/docs/FileSchemaTestClass.md index d32819b3578..29c3aac8c56 100644 --- a/samples/client/petstore/ruby/docs/FileSchemaTestClass.md +++ b/samples/client/petstore/ruby/docs/FileSchemaTestClass.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **file** | **File** | | [optional] **files** | **Array<File>** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::FileSchemaTestClass.new(file: null, + files: null) +``` + diff --git a/samples/client/petstore/ruby/docs/FormatTest.md b/samples/client/petstore/ruby/docs/FormatTest.md index ad9b8191dce..020ff1eb051 100644 --- a/samples/client/petstore/ruby/docs/FormatTest.md +++ b/samples/client/petstore/ruby/docs/FormatTest.md @@ -17,4 +17,24 @@ Name | Type | Description | Notes **uuid** | **String** | | [optional] **password** | **String** | | +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::FormatTest.new(integer: null, + int32: null, + int64: null, + number: null, + float: null, + double: null, + string: null, + byte: null, + binary: null, + date: null, + date_time: null, + uuid: 72f98069-206d-4f12-9f12-3d1e525a8e84, + password: null) +``` + diff --git a/samples/client/petstore/ruby/docs/HasOnlyReadOnly.md b/samples/client/petstore/ruby/docs/HasOnlyReadOnly.md index 16de3c060cc..b86538fb1d0 100644 --- a/samples/client/petstore/ruby/docs/HasOnlyReadOnly.md +++ b/samples/client/petstore/ruby/docs/HasOnlyReadOnly.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **bar** | **String** | | [optional] **foo** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::HasOnlyReadOnly.new(bar: null, + foo: null) +``` + diff --git a/samples/client/petstore/ruby/docs/List.md b/samples/client/petstore/ruby/docs/List.md index 211d299f671..9e577145bbd 100644 --- a/samples/client/petstore/ruby/docs/List.md +++ b/samples/client/petstore/ruby/docs/List.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **_123_list** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::List.new(_123_list: null) +``` + diff --git a/samples/client/petstore/ruby/docs/MapTest.md b/samples/client/petstore/ruby/docs/MapTest.md index 54e16e1933e..e8ff385a544 100644 --- a/samples/client/petstore/ruby/docs/MapTest.md +++ b/samples/client/petstore/ruby/docs/MapTest.md @@ -8,4 +8,15 @@ Name | Type | Description | Notes **direct_map** | **Hash<String, BOOLEAN>** | | [optional] **indirect_map** | **Hash<String, BOOLEAN>** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::MapTest.new(map_map_of_string: null, + map_of_enum_string: null, + direct_map: null, + indirect_map: null) +``` + diff --git a/samples/client/petstore/ruby/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/ruby/docs/MixedPropertiesAndAdditionalPropertiesClass.md index dcb02e2ffa6..5c7f0accb58 100644 --- a/samples/client/petstore/ruby/docs/MixedPropertiesAndAdditionalPropertiesClass.md +++ b/samples/client/petstore/ruby/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -7,4 +7,14 @@ Name | Type | Description | Notes **date_time** | **DateTime** | | [optional] **map** | [**Hash<String, Animal>**](Animal.md) | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::MixedPropertiesAndAdditionalPropertiesClass.new(uuid: null, + date_time: null, + map: null) +``` + diff --git a/samples/client/petstore/ruby/docs/Model200Response.md b/samples/client/petstore/ruby/docs/Model200Response.md index e745da1a756..94aa48f0818 100644 --- a/samples/client/petstore/ruby/docs/Model200Response.md +++ b/samples/client/petstore/ruby/docs/Model200Response.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **name** | **Integer** | | [optional] **_class** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Model200Response.new(name: null, + _class: null) +``` + diff --git a/samples/client/petstore/ruby/docs/ModelReturn.md b/samples/client/petstore/ruby/docs/ModelReturn.md index dfcfff1dd06..193e2eb4da8 100644 --- a/samples/client/petstore/ruby/docs/ModelReturn.md +++ b/samples/client/petstore/ruby/docs/ModelReturn.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **_return** | **Integer** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::ModelReturn.new(_return: null) +``` + diff --git a/samples/client/petstore/ruby/docs/Name.md b/samples/client/petstore/ruby/docs/Name.md index 1ae49f8ee1b..575b9f1585f 100644 --- a/samples/client/petstore/ruby/docs/Name.md +++ b/samples/client/petstore/ruby/docs/Name.md @@ -8,4 +8,15 @@ Name | Type | Description | Notes **property** | **String** | | [optional] **_123_number** | **Integer** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Name.new(name: null, + snake_case: null, + property: null, + _123_number: null) +``` + diff --git a/samples/client/petstore/ruby/docs/NumberOnly.md b/samples/client/petstore/ruby/docs/NumberOnly.md index 4be8a12a79d..c12410c8c86 100644 --- a/samples/client/petstore/ruby/docs/NumberOnly.md +++ b/samples/client/petstore/ruby/docs/NumberOnly.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **just_number** | **Float** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::NumberOnly.new(just_number: null) +``` + diff --git a/samples/client/petstore/ruby/docs/Order.md b/samples/client/petstore/ruby/docs/Order.md index 52a832c5106..70a1d3d92f8 100644 --- a/samples/client/petstore/ruby/docs/Order.md +++ b/samples/client/petstore/ruby/docs/Order.md @@ -10,4 +10,17 @@ Name | Type | Description | Notes **status** | **String** | Order Status | [optional] **complete** | **BOOLEAN** | | [optional] [default to false] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Order.new(id: null, + pet_id: null, + quantity: null, + ship_date: null, + status: null, + complete: null) +``` + diff --git a/samples/client/petstore/ruby/docs/OuterComposite.md b/samples/client/petstore/ruby/docs/OuterComposite.md index e1548870a7b..a93fef0ee57 100644 --- a/samples/client/petstore/ruby/docs/OuterComposite.md +++ b/samples/client/petstore/ruby/docs/OuterComposite.md @@ -7,4 +7,14 @@ Name | Type | Description | Notes **my_string** | **String** | | [optional] **my_boolean** | **BOOLEAN** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::OuterComposite.new(my_number: null, + my_string: null, + my_boolean: null) +``` + diff --git a/samples/client/petstore/ruby/docs/OuterEnum.md b/samples/client/petstore/ruby/docs/OuterEnum.md index 60d87c12381..3c63edf54a5 100644 --- a/samples/client/petstore/ruby/docs/OuterEnum.md +++ b/samples/client/petstore/ruby/docs/OuterEnum.md @@ -4,4 +4,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::OuterEnum.new() +``` + diff --git a/samples/client/petstore/ruby/docs/Pet.md b/samples/client/petstore/ruby/docs/Pet.md index f4320a0b72b..49318999bd1 100644 --- a/samples/client/petstore/ruby/docs/Pet.md +++ b/samples/client/petstore/ruby/docs/Pet.md @@ -10,4 +10,17 @@ Name | Type | Description | Notes **tags** | [**Array<Tag>**](Tag.md) | | [optional] **status** | **String** | pet status in the store | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Pet.new(id: null, + category: null, + name: doggie, + photo_urls: null, + tags: null, + status: null) +``` + diff --git a/samples/client/petstore/ruby/docs/ReadOnlyFirst.md b/samples/client/petstore/ruby/docs/ReadOnlyFirst.md index e49b5119478..8d0bf7ab923 100644 --- a/samples/client/petstore/ruby/docs/ReadOnlyFirst.md +++ b/samples/client/petstore/ruby/docs/ReadOnlyFirst.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **bar** | **String** | | [optional] **baz** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::ReadOnlyFirst.new(bar: null, + baz: null) +``` + diff --git a/samples/client/petstore/ruby/docs/SpecialModelName.md b/samples/client/petstore/ruby/docs/SpecialModelName.md index 581ab6907ef..753a6ea26bf 100644 --- a/samples/client/petstore/ruby/docs/SpecialModelName.md +++ b/samples/client/petstore/ruby/docs/SpecialModelName.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **special_property_name** | **Integer** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::SpecialModelName.new(special_property_name: null) +``` + diff --git a/samples/client/petstore/ruby/docs/Tag.md b/samples/client/petstore/ruby/docs/Tag.md index 5bd94d6c04e..717fe6469c4 100644 --- a/samples/client/petstore/ruby/docs/Tag.md +++ b/samples/client/petstore/ruby/docs/Tag.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **id** | **Integer** | | [optional] **name** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Tag.new(id: null, + name: null) +``` + diff --git a/samples/client/petstore/ruby/docs/TypeHolderDefault.md b/samples/client/petstore/ruby/docs/TypeHolderDefault.md index eaadc04a66c..74da2cb0b63 100644 --- a/samples/client/petstore/ruby/docs/TypeHolderDefault.md +++ b/samples/client/petstore/ruby/docs/TypeHolderDefault.md @@ -9,4 +9,16 @@ Name | Type | Description | Notes **bool_item** | **BOOLEAN** | | [default to true] **array_item** | **Array<Integer>** | | +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::TypeHolderDefault.new(string_item: null, + number_item: null, + integer_item: null, + bool_item: null, + array_item: null) +``` + diff --git a/samples/client/petstore/ruby/docs/TypeHolderExample.md b/samples/client/petstore/ruby/docs/TypeHolderExample.md index f93b2d4de4e..3ba999a9c83 100644 --- a/samples/client/petstore/ruby/docs/TypeHolderExample.md +++ b/samples/client/petstore/ruby/docs/TypeHolderExample.md @@ -9,4 +9,16 @@ Name | Type | Description | Notes **bool_item** | **BOOLEAN** | | **array_item** | **Array<Integer>** | | +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::TypeHolderExample.new(string_item: what, + number_item: 1.234, + integer_item: -2, + bool_item: true, + array_item: [0, 1, 2, 3]) +``` + diff --git a/samples/client/petstore/ruby/docs/User.md b/samples/client/petstore/ruby/docs/User.md index bd76116e023..25df1a9a218 100644 --- a/samples/client/petstore/ruby/docs/User.md +++ b/samples/client/petstore/ruby/docs/User.md @@ -12,4 +12,19 @@ Name | Type | Description | Notes **phone** | **String** | | [optional] **user_status** | **Integer** | User Status | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::User.new(id: null, + username: null, + first_name: null, + last_name: null, + email: null, + password: null, + phone: null, + user_status: null) +``` + diff --git a/samples/client/petstore/ruby/docs/XmlItem.md b/samples/client/petstore/ruby/docs/XmlItem.md index 8b0f9ddb9ec..52765aeddfc 100644 --- a/samples/client/petstore/ruby/docs/XmlItem.md +++ b/samples/client/petstore/ruby/docs/XmlItem.md @@ -33,4 +33,40 @@ Name | Type | Description | Notes **prefix_ns_array** | **Array<Integer>** | | [optional] **prefix_ns_wrapped_array** | **Array<Integer>** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::XmlItem.new(attribute_string: string, + attribute_number: 1.234, + attribute_integer: -2, + attribute_boolean: true, + wrapped_array: null, + name_string: string, + name_number: 1.234, + name_integer: -2, + name_boolean: true, + name_array: null, + name_wrapped_array: null, + prefix_string: string, + prefix_number: 1.234, + prefix_integer: -2, + prefix_boolean: true, + prefix_array: null, + prefix_wrapped_array: null, + namespace_string: string, + namespace_number: 1.234, + namespace_integer: -2, + namespace_boolean: true, + namespace_array: null, + namespace_wrapped_array: null, + prefix_ns_string: string, + prefix_ns_number: 1.234, + prefix_ns_integer: -2, + prefix_ns_boolean: true, + prefix_ns_array: null, + prefix_ns_wrapped_array: null) +``` + diff --git a/samples/client/petstore/ruby/lib/petstore/api_error.rb b/samples/client/petstore/ruby/lib/petstore/api_error.rb index 66bf1edb437..fdef5a7fd20 100644 --- a/samples/client/petstore/ruby/lib/petstore/api_error.rb +++ b/samples/client/petstore/ruby/lib/petstore/api_error.rb @@ -34,5 +34,24 @@ module Petstore super arg end end + + # Override to_s to display a friendly error message + def to_s + message + end + + def message + if @message.nil? + msg = "Error message: the server returns an error" + else + msg = @message + end + + msg += "\nHTTP status code: #{code}" if code + msg += "\nResponse headers: #{response_headers}" if response_headers + msg += "\nResponse body: #{response_body}" if response_body + + msg + end end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb index 677fcc53190..b7605329f76 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb @@ -37,18 +37,25 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::AdditionalPropertiesClass` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::AdditionalPropertiesClass`. 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.has_key?(:'map_property') + if attributes.key?(:'map_property') if (value = attributes[:'map_property']).is_a?(Hash) self.map_property = value end end - if attributes.has_key?(:'map_of_map_property') + if attributes.key?(:'map_of_map_property') if (value = attributes[:'map_of_map_property']).is_a?(Hash) self.map_of_map_property = value end diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index cf332acd704..34a5173da3f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -42,16 +42,23 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) - - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } - - if attributes.has_key?(:'className') - self.class_name = attributes[:'className'] + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Animal` initialize method" end - if attributes.has_key?(:'color') + # 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::Animal`. 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?(:'class_name') + self.class_name = attributes[:'class_name'] + end + + if attributes.key?(:'color') self.color = attributes[:'color'] else self.color = 'red' diff --git a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb index b9bf69a9e9e..54183e3e782 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -41,20 +41,27 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ApiResponse` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::ApiResponse`. 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.has_key?(:'code') + if attributes.key?(:'code') self.code = attributes[:'code'] end - if attributes.has_key?(:'type') + if attributes.key?(:'type') self.type = attributes[:'type'] end - if attributes.has_key?(:'message') + if attributes.key?(:'message') self.message = attributes[:'message'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb b/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb index 8ffa47da6a6..cb7cd570949 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb @@ -33,13 +33,20 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ArrayOfArrayOfNumberOnly` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::ArrayOfArrayOfNumberOnly`. 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.has_key?(:'ArrayArrayNumber') - if (value = attributes[:'ArrayArrayNumber']).is_a?(Array) + if attributes.key?(:'array_array_number') + if (value = attributes[:'array_array_number']).is_a?(Array) self.array_array_number = value end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb b/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb index dc737f6a7f6..9a1af59a50e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb @@ -33,13 +33,20 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ArrayOfNumberOnly` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::ArrayOfNumberOnly`. 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.has_key?(:'ArrayNumber') - if (value = attributes[:'ArrayNumber']).is_a?(Array) + if attributes.key?(:'array_number') + if (value = attributes[:'array_number']).is_a?(Array) self.array_number = value end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/array_test.rb b/samples/client/petstore/ruby/lib/petstore/models/array_test.rb index 067eca1ca86..03de89bc69d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/array_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/array_test.rb @@ -41,24 +41,31 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ArrayTest` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::ArrayTest`. 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.has_key?(:'array_of_string') + if attributes.key?(:'array_of_string') if (value = attributes[:'array_of_string']).is_a?(Array) self.array_of_string = value end end - if attributes.has_key?(:'array_array_of_integer') + if attributes.key?(:'array_array_of_integer') if (value = attributes[:'array_array_of_integer']).is_a?(Array) self.array_array_of_integer = value end end - if attributes.has_key?(:'array_array_of_model') + if attributes.key?(:'array_array_of_model') if (value = attributes[:'array_array_of_model']).is_a?(Array) self.array_array_of_model = value end diff --git a/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb b/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb index fe0eac256d7..7c2480f0378 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/capitalization.rb @@ -54,33 +54,40 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) - - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } - - if attributes.has_key?(:'smallCamel') - self.small_camel = attributes[:'smallCamel'] + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Capitalization` initialize method" end - if attributes.has_key?(:'CapitalCamel') - self.capital_camel = attributes[:'CapitalCamel'] + # 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::Capitalization`. 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?(:'small_camel') + self.small_camel = attributes[:'small_camel'] end - if attributes.has_key?(:'small_Snake') - self.small_snake = attributes[:'small_Snake'] + if attributes.key?(:'capital_camel') + self.capital_camel = attributes[:'capital_camel'] end - if attributes.has_key?(:'Capital_Snake') - self.capital_snake = attributes[:'Capital_Snake'] + if attributes.key?(:'small_snake') + self.small_snake = attributes[:'small_snake'] end - if attributes.has_key?(:'SCA_ETH_Flow_Points') - self.sca_eth_flow_points = attributes[:'SCA_ETH_Flow_Points'] + if attributes.key?(:'capital_snake') + self.capital_snake = attributes[:'capital_snake'] end - if attributes.has_key?(:'ATT_NAME') - self.att_name = attributes[:'ATT_NAME'] + if attributes.key?(:'sca_eth_flow_points') + self.sca_eth_flow_points = attributes[:'sca_eth_flow_points'] + end + + if attributes.key?(:'att_name') + self.att_name = attributes[:'att_name'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index ea7b6ab023c..fc126f6d4f1 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -40,15 +40,22 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Cat` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Cat`. 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 + } # call parent's initialize super(attributes) - if attributes.has_key?(:'declawed') + if attributes.key?(:'declawed') self.declawed = attributes[:'declawed'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb index 7e6972989d5..766999435ad 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -37,16 +37,23 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Category` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Category`. 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.has_key?(:'id') + if attributes.key?(:'id') self.id = attributes[:'id'] end - if attributes.has_key?(:'name') + if attributes.key?(:'name') self.name = attributes[:'name'] else self.name = 'default-name' diff --git a/samples/client/petstore/ruby/lib/petstore/models/class_model.rb b/samples/client/petstore/ruby/lib/petstore/models/class_model.rb index 3864b48b8d2..70f888627a4 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/class_model.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/class_model.rb @@ -34,12 +34,19 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ClassModel` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::ClassModel`. 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.has_key?(:'_class') + if attributes.key?(:'_class') self._class = attributes[:'_class'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/client.rb b/samples/client/petstore/ruby/lib/petstore/models/client.rb index cb67fe62a36..df4a65ed366 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/client.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/client.rb @@ -33,12 +33,19 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Client` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Client`. 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.has_key?(:'client') + if attributes.key?(:'client') self.client = attributes[:'client'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index 82c9b239926..55351bc099d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -40,15 +40,22 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Dog` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Dog`. 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 + } # call parent's initialize super(attributes) - if attributes.has_key?(:'breed') + if attributes.key?(:'breed') self.breed = attributes[:'breed'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb b/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb index 6c21580387d..ada854d6f84 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb @@ -59,16 +59,23 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::EnumArrays` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::EnumArrays`. 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.has_key?(:'just_symbol') + if attributes.key?(:'just_symbol') self.just_symbol = attributes[:'just_symbol'] end - if attributes.has_key?(:'array_enum') + if attributes.key?(:'array_enum') if (value = attributes[:'array_enum']).is_a?(Array) self.array_enum = value end diff --git a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb index 89870ae722b..2b0634fc36e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/enum_test.rb @@ -71,29 +71,36 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::EnumTest` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::EnumTest`. 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.has_key?(:'enum_string') + if attributes.key?(:'enum_string') self.enum_string = attributes[:'enum_string'] end - if attributes.has_key?(:'enum_string_required') + if attributes.key?(:'enum_string_required') self.enum_string_required = attributes[:'enum_string_required'] end - if attributes.has_key?(:'enum_integer') + if attributes.key?(:'enum_integer') self.enum_integer = attributes[:'enum_integer'] end - if attributes.has_key?(:'enum_number') + if attributes.key?(:'enum_number') self.enum_number = attributes[:'enum_number'] end - if attributes.has_key?(:'outerEnum') - self.outer_enum = attributes[:'outerEnum'] + if attributes.key?(:'outer_enum') + self.outer_enum = attributes[:'outer_enum'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/file.rb b/samples/client/petstore/ruby/lib/petstore/models/file.rb index 2b91d719ecf..54ce33ac5ba 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/file.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/file.rb @@ -35,13 +35,20 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::File` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::File`. 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.has_key?(:'sourceURI') - self.source_uri = attributes[:'sourceURI'] + if attributes.key?(:'source_uri') + self.source_uri = attributes[:'source_uri'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb b/samples/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb index 1c10ff41fb6..ef038a50e8e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb @@ -37,16 +37,23 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::FileSchemaTestClass` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::FileSchemaTestClass`. 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.has_key?(:'file') + if attributes.key?(:'file') self.file = attributes[:'file'] end - if attributes.has_key?(:'files') + if attributes.key?(:'files') if (value = attributes[:'files']).is_a?(Array) self.files = value end diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index e588e0d65eb..fd4a46d674a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -81,60 +81,67 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::FormatTest` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::FormatTest`. 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.has_key?(:'integer') + if attributes.key?(:'integer') self.integer = attributes[:'integer'] end - if attributes.has_key?(:'int32') + if attributes.key?(:'int32') self.int32 = attributes[:'int32'] end - if attributes.has_key?(:'int64') + if attributes.key?(:'int64') self.int64 = attributes[:'int64'] end - if attributes.has_key?(:'number') + if attributes.key?(:'number') self.number = attributes[:'number'] end - if attributes.has_key?(:'float') + if attributes.key?(:'float') self.float = attributes[:'float'] end - if attributes.has_key?(:'double') + if attributes.key?(:'double') self.double = attributes[:'double'] end - if attributes.has_key?(:'string') + if attributes.key?(:'string') self.string = attributes[:'string'] end - if attributes.has_key?(:'byte') + if attributes.key?(:'byte') self.byte = attributes[:'byte'] end - if attributes.has_key?(:'binary') + if attributes.key?(:'binary') self.binary = attributes[:'binary'] end - if attributes.has_key?(:'date') + if attributes.key?(:'date') self.date = attributes[:'date'] end - if attributes.has_key?(:'dateTime') - self.date_time = attributes[:'dateTime'] + if attributes.key?(:'date_time') + self.date_time = attributes[:'date_time'] end - if attributes.has_key?(:'uuid') + if attributes.key?(:'uuid') self.uuid = attributes[:'uuid'] end - if attributes.has_key?(:'password') + if attributes.key?(:'password') self.password = attributes[:'password'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb b/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb index 84d61b08c71..65f6afd90f6 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb @@ -37,16 +37,23 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::HasOnlyReadOnly` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::HasOnlyReadOnly`. 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.has_key?(:'bar') + if attributes.key?(:'bar') self.bar = attributes[:'bar'] end - if attributes.has_key?(:'foo') + if attributes.key?(:'foo') self.foo = attributes[:'foo'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/list.rb b/samples/client/petstore/ruby/lib/petstore/models/list.rb index 0155981d0d4..0d3e43c0b09 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/list.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/list.rb @@ -33,13 +33,20 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::List` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::List`. 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.has_key?(:'123-list') - self._123_list = attributes[:'123-list'] + if attributes.key?(:'_123_list') + self._123_list = attributes[:'_123_list'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/map_test.rb b/samples/client/petstore/ruby/lib/petstore/models/map_test.rb index d8e5b805a9a..9c4fc30dabb 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/map_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/map_test.rb @@ -67,30 +67,37 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::MapTest` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::MapTest`. 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.has_key?(:'map_map_of_string') + if attributes.key?(:'map_map_of_string') if (value = attributes[:'map_map_of_string']).is_a?(Hash) self.map_map_of_string = value end end - if attributes.has_key?(:'map_of_enum_string') + if attributes.key?(:'map_of_enum_string') if (value = attributes[:'map_of_enum_string']).is_a?(Hash) self.map_of_enum_string = value end end - if attributes.has_key?(:'direct_map') + if attributes.key?(:'direct_map') if (value = attributes[:'direct_map']).is_a?(Hash) self.direct_map = value end end - if attributes.has_key?(:'indirect_map') + if attributes.key?(:'indirect_map') if (value = attributes[:'indirect_map']).is_a?(Hash) self.indirect_map = value end diff --git a/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 1a8f783bcc2..ef0e1419137 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -41,20 +41,27 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::MixedPropertiesAndAdditionalPropertiesClass` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::MixedPropertiesAndAdditionalPropertiesClass`. 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.has_key?(:'uuid') + if attributes.key?(:'uuid') self.uuid = attributes[:'uuid'] end - if attributes.has_key?(:'dateTime') - self.date_time = attributes[:'dateTime'] + if attributes.key?(:'date_time') + self.date_time = attributes[:'date_time'] end - if attributes.has_key?(:'map') + if attributes.key?(:'map') if (value = attributes[:'map']).is_a?(Hash) self.map = value end diff --git a/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb b/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb index c07c547f072..70914ae80c3 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model200_response.rb @@ -38,17 +38,24 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Model200Response` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Model200Response`. 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.has_key?(:'name') + if attributes.key?(:'name') self.name = attributes[:'name'] end - if attributes.has_key?(:'class') - self._class = attributes[:'class'] + if attributes.key?(:'_class') + self._class = attributes[:'_class'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb index 3311456698e..a261b73ffef 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -34,13 +34,20 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ModelReturn` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::ModelReturn`. 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.has_key?(:'return') - self._return = attributes[:'return'] + if attributes.key?(:'_return') + self._return = attributes[:'_return'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index c7e2bea5a9c..cdb941cd20d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -46,25 +46,32 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Name` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Name`. 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.has_key?(:'name') + if attributes.key?(:'name') self.name = attributes[:'name'] end - if attributes.has_key?(:'snake_case') + if attributes.key?(:'snake_case') self.snake_case = attributes[:'snake_case'] end - if attributes.has_key?(:'property') + if attributes.key?(:'property') self.property = attributes[:'property'] end - if attributes.has_key?(:'123Number') - self._123_number = attributes[:'123Number'] + if attributes.key?(:'_123_number') + self._123_number = attributes[:'_123_number'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/number_only.rb b/samples/client/petstore/ruby/lib/petstore/models/number_only.rb index 9ea2e5d2b2b..e3e512cde73 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/number_only.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/number_only.rb @@ -33,13 +33,20 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::NumberOnly` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::NumberOnly`. 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.has_key?(:'JustNumber') - self.just_number = attributes[:'JustNumber'] + if attributes.key?(:'just_number') + self.just_number = attributes[:'just_number'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index c9254d8ef61..4d2118ee095 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -76,32 +76,39 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Order` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Order`. 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.has_key?(:'id') + if attributes.key?(:'id') self.id = attributes[:'id'] end - if attributes.has_key?(:'petId') - self.pet_id = attributes[:'petId'] + if attributes.key?(:'pet_id') + self.pet_id = attributes[:'pet_id'] end - if attributes.has_key?(:'quantity') + if attributes.key?(:'quantity') self.quantity = attributes[:'quantity'] end - if attributes.has_key?(:'shipDate') - self.ship_date = attributes[:'shipDate'] + if attributes.key?(:'ship_date') + self.ship_date = attributes[:'ship_date'] end - if attributes.has_key?(:'status') + if attributes.key?(:'status') self.status = attributes[:'status'] end - if attributes.has_key?(:'complete') + if attributes.key?(:'complete') self.complete = attributes[:'complete'] else self.complete = false diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb index b42c8ad462d..d7dc16af69a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb @@ -41,20 +41,27 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::OuterComposite` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::OuterComposite`. 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.has_key?(:'my_number') + if attributes.key?(:'my_number') self.my_number = attributes[:'my_number'] end - if attributes.has_key?(:'my_string') + if attributes.key?(:'my_string') self.my_string = attributes[:'my_string'] end - if attributes.has_key?(:'my_boolean') + if attributes.key?(:'my_boolean') self.my_boolean = attributes[:'my_boolean'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index a2fd3bd5b8b..7bf0672af3c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -76,36 +76,43 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Pet` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Pet`. 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.has_key?(:'id') + if attributes.key?(:'id') self.id = attributes[:'id'] end - if attributes.has_key?(:'category') + if attributes.key?(:'category') self.category = attributes[:'category'] end - if attributes.has_key?(:'name') + if attributes.key?(:'name') self.name = attributes[:'name'] end - if attributes.has_key?(:'photoUrls') - if (value = attributes[:'photoUrls']).is_a?(Array) + if attributes.key?(:'photo_urls') + if (value = attributes[:'photo_urls']).is_a?(Array) self.photo_urls = value end end - if attributes.has_key?(:'tags') + if attributes.key?(:'tags') if (value = attributes[:'tags']).is_a?(Array) self.tags = value end end - if attributes.has_key?(:'status') + if attributes.key?(:'status') self.status = attributes[:'status'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb b/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb index 350e66716af..b2fa0e4374d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/read_only_first.rb @@ -37,16 +37,23 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ReadOnlyFirst` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::ReadOnlyFirst`. 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.has_key?(:'bar') + if attributes.key?(:'bar') self.bar = attributes[:'bar'] end - if attributes.has_key?(:'baz') + if attributes.key?(:'baz') self.baz = attributes[:'baz'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb index ad676f4bfcb..960713915f6 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb @@ -33,13 +33,20 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::SpecialModelName` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::SpecialModelName`. 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.has_key?(:'$special[property.name]') - self.special_property_name = attributes[:'$special[property.name]'] + if attributes.key?(:'special_property_name') + self.special_property_name = attributes[:'special_property_name'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb index f15575379ea..2b8ae4e2505 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -37,16 +37,23 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Tag` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Tag`. 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.has_key?(:'id') + if attributes.key?(:'id') self.id = attributes[:'id'] end - if attributes.has_key?(:'name') + if attributes.key?(:'name') self.name = attributes[:'name'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/type_holder_default.rb b/samples/client/petstore/ruby/lib/petstore/models/type_holder_default.rb index 5179ffcab86..ffbce832390 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/type_holder_default.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/type_holder_default.rb @@ -49,32 +49,39 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::TypeHolderDefault` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::TypeHolderDefault`. 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.has_key?(:'string_item') + if attributes.key?(:'string_item') self.string_item = attributes[:'string_item'] else self.string_item = 'what' end - if attributes.has_key?(:'number_item') + if attributes.key?(:'number_item') self.number_item = attributes[:'number_item'] end - if attributes.has_key?(:'integer_item') + if attributes.key?(:'integer_item') self.integer_item = attributes[:'integer_item'] end - if attributes.has_key?(:'bool_item') + if attributes.key?(:'bool_item') self.bool_item = attributes[:'bool_item'] else self.bool_item = true end - if attributes.has_key?(:'array_item') + if attributes.key?(:'array_item') if (value = attributes[:'array_item']).is_a?(Array) self.array_item = value end diff --git a/samples/client/petstore/ruby/lib/petstore/models/type_holder_example.rb b/samples/client/petstore/ruby/lib/petstore/models/type_holder_example.rb index ce8a178030c..d3f1d6012fd 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/type_holder_example.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/type_holder_example.rb @@ -49,28 +49,35 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::TypeHolderExample` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::TypeHolderExample`. 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.has_key?(:'string_item') + if attributes.key?(:'string_item') self.string_item = attributes[:'string_item'] end - if attributes.has_key?(:'number_item') + if attributes.key?(:'number_item') self.number_item = attributes[:'number_item'] end - if attributes.has_key?(:'integer_item') + if attributes.key?(:'integer_item') self.integer_item = attributes[:'integer_item'] end - if attributes.has_key?(:'bool_item') + if attributes.key?(:'bool_item') self.bool_item = attributes[:'bool_item'] end - if attributes.has_key?(:'array_item') + if attributes.key?(:'array_item') if (value = attributes[:'array_item']).is_a?(Array) self.array_item = value end diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb index e4138a400f1..365ad8a0757 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -62,41 +62,48 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::User` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::User`. 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.has_key?(:'id') + if attributes.key?(:'id') self.id = attributes[:'id'] end - if attributes.has_key?(:'username') + if attributes.key?(:'username') self.username = attributes[:'username'] end - if attributes.has_key?(:'firstName') - self.first_name = attributes[:'firstName'] + if attributes.key?(:'first_name') + self.first_name = attributes[:'first_name'] end - if attributes.has_key?(:'lastName') - self.last_name = attributes[:'lastName'] + if attributes.key?(:'last_name') + self.last_name = attributes[:'last_name'] end - if attributes.has_key?(:'email') + if attributes.key?(:'email') self.email = attributes[:'email'] end - if attributes.has_key?(:'password') + if attributes.key?(:'password') self.password = attributes[:'password'] end - if attributes.has_key?(:'phone') + if attributes.key?(:'phone') self.phone = attributes[:'phone'] end - if attributes.has_key?(:'userStatus') - self.user_status = attributes[:'userStatus'] + if attributes.key?(:'user_status') + self.user_status = attributes[:'user_status'] end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/xml_item.rb b/samples/client/petstore/ruby/lib/petstore/models/xml_item.rb index 455167f8662..5d7059cf95f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/xml_item.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/xml_item.rb @@ -145,140 +145,147 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::XmlItem` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::XmlItem`. 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.has_key?(:'attribute_string') + if attributes.key?(:'attribute_string') self.attribute_string = attributes[:'attribute_string'] end - if attributes.has_key?(:'attribute_number') + if attributes.key?(:'attribute_number') self.attribute_number = attributes[:'attribute_number'] end - if attributes.has_key?(:'attribute_integer') + if attributes.key?(:'attribute_integer') self.attribute_integer = attributes[:'attribute_integer'] end - if attributes.has_key?(:'attribute_boolean') + if attributes.key?(:'attribute_boolean') self.attribute_boolean = attributes[:'attribute_boolean'] end - if attributes.has_key?(:'wrapped_array') + if attributes.key?(:'wrapped_array') if (value = attributes[:'wrapped_array']).is_a?(Array) self.wrapped_array = value end end - if attributes.has_key?(:'name_string') + if attributes.key?(:'name_string') self.name_string = attributes[:'name_string'] end - if attributes.has_key?(:'name_number') + if attributes.key?(:'name_number') self.name_number = attributes[:'name_number'] end - if attributes.has_key?(:'name_integer') + if attributes.key?(:'name_integer') self.name_integer = attributes[:'name_integer'] end - if attributes.has_key?(:'name_boolean') + if attributes.key?(:'name_boolean') self.name_boolean = attributes[:'name_boolean'] end - if attributes.has_key?(:'name_array') + if attributes.key?(:'name_array') if (value = attributes[:'name_array']).is_a?(Array) self.name_array = value end end - if attributes.has_key?(:'name_wrapped_array') + if attributes.key?(:'name_wrapped_array') if (value = attributes[:'name_wrapped_array']).is_a?(Array) self.name_wrapped_array = value end end - if attributes.has_key?(:'prefix_string') + if attributes.key?(:'prefix_string') self.prefix_string = attributes[:'prefix_string'] end - if attributes.has_key?(:'prefix_number') + if attributes.key?(:'prefix_number') self.prefix_number = attributes[:'prefix_number'] end - if attributes.has_key?(:'prefix_integer') + if attributes.key?(:'prefix_integer') self.prefix_integer = attributes[:'prefix_integer'] end - if attributes.has_key?(:'prefix_boolean') + if attributes.key?(:'prefix_boolean') self.prefix_boolean = attributes[:'prefix_boolean'] end - if attributes.has_key?(:'prefix_array') + if attributes.key?(:'prefix_array') if (value = attributes[:'prefix_array']).is_a?(Array) self.prefix_array = value end end - if attributes.has_key?(:'prefix_wrapped_array') + if attributes.key?(:'prefix_wrapped_array') if (value = attributes[:'prefix_wrapped_array']).is_a?(Array) self.prefix_wrapped_array = value end end - if attributes.has_key?(:'namespace_string') + if attributes.key?(:'namespace_string') self.namespace_string = attributes[:'namespace_string'] end - if attributes.has_key?(:'namespace_number') + if attributes.key?(:'namespace_number') self.namespace_number = attributes[:'namespace_number'] end - if attributes.has_key?(:'namespace_integer') + if attributes.key?(:'namespace_integer') self.namespace_integer = attributes[:'namespace_integer'] end - if attributes.has_key?(:'namespace_boolean') + if attributes.key?(:'namespace_boolean') self.namespace_boolean = attributes[:'namespace_boolean'] end - if attributes.has_key?(:'namespace_array') + if attributes.key?(:'namespace_array') if (value = attributes[:'namespace_array']).is_a?(Array) self.namespace_array = value end end - if attributes.has_key?(:'namespace_wrapped_array') + if attributes.key?(:'namespace_wrapped_array') if (value = attributes[:'namespace_wrapped_array']).is_a?(Array) self.namespace_wrapped_array = value end end - if attributes.has_key?(:'prefix_ns_string') + if attributes.key?(:'prefix_ns_string') self.prefix_ns_string = attributes[:'prefix_ns_string'] end - if attributes.has_key?(:'prefix_ns_number') + if attributes.key?(:'prefix_ns_number') self.prefix_ns_number = attributes[:'prefix_ns_number'] end - if attributes.has_key?(:'prefix_ns_integer') + if attributes.key?(:'prefix_ns_integer') self.prefix_ns_integer = attributes[:'prefix_ns_integer'] end - if attributes.has_key?(:'prefix_ns_boolean') + if attributes.key?(:'prefix_ns_boolean') self.prefix_ns_boolean = attributes[:'prefix_ns_boolean'] end - if attributes.has_key?(:'prefix_ns_array') + if attributes.key?(:'prefix_ns_array') if (value = attributes[:'prefix_ns_array']).is_a?(Array) self.prefix_ns_array = value end end - if attributes.has_key?(:'prefix_ns_wrapped_array') + if attributes.key?(:'prefix_ns_wrapped_array') if (value = attributes[:'prefix_ns_wrapped_array']).is_a?(Array) self.prefix_ns_wrapped_array = value end diff --git a/samples/openapi3/client/petstore/ruby/.travis.yml b/samples/openapi3/client/petstore/ruby/.travis.yml new file mode 100644 index 00000000000..d2d526df594 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/.travis.yml @@ -0,0 +1,11 @@ +language: ruby +cache: bundler +rvm: + - 2.3 + - 2.4 + - 2.5 +script: + - bundle install --path vendor/bundle + - bundle exec rspec + - gem build petstore.gemspec + - gem install ./petstore-1.0.0.gem diff --git a/samples/openapi3/client/petstore/ruby/docs/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/ruby/docs/AdditionalPropertiesClass.md index c3ee2cdf637..6e518a5e4ca 100644 --- a/samples/openapi3/client/petstore/ruby/docs/AdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/ruby/docs/AdditionalPropertiesClass.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **map_property** | **Hash<String, String>** | | [optional] **map_of_map_property** | **Hash<String, Hash<String, String>>** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::AdditionalPropertiesClass.new(map_property: null, + map_of_map_property: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/Animal.md b/samples/openapi3/client/petstore/ruby/docs/Animal.md index 077e6c2d87c..03edcf2fca9 100644 --- a/samples/openapi3/client/petstore/ruby/docs/Animal.md +++ b/samples/openapi3/client/petstore/ruby/docs/Animal.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **class_name** | **String** | | **color** | **String** | | [optional] [default to 'red'] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Animal.new(class_name: null, + color: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/ApiResponse.md b/samples/openapi3/client/petstore/ruby/docs/ApiResponse.md index 843f9cc525b..747ebff5559 100644 --- a/samples/openapi3/client/petstore/ruby/docs/ApiResponse.md +++ b/samples/openapi3/client/petstore/ruby/docs/ApiResponse.md @@ -7,4 +7,14 @@ Name | Type | Description | Notes **type** | **String** | | [optional] **message** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::ApiResponse.new(code: null, + type: null, + message: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/ArrayOfArrayOfNumberOnly.md b/samples/openapi3/client/petstore/ruby/docs/ArrayOfArrayOfNumberOnly.md index 003cf9a8d6d..c7af572b3de 100644 --- a/samples/openapi3/client/petstore/ruby/docs/ArrayOfArrayOfNumberOnly.md +++ b/samples/openapi3/client/petstore/ruby/docs/ArrayOfArrayOfNumberOnly.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **array_array_number** | **Array<Array<Float>>** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::ArrayOfArrayOfNumberOnly.new(array_array_number: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/ArrayOfNumberOnly.md b/samples/openapi3/client/petstore/ruby/docs/ArrayOfNumberOnly.md index c2b9fada4f8..b2ffb7f78ef 100644 --- a/samples/openapi3/client/petstore/ruby/docs/ArrayOfNumberOnly.md +++ b/samples/openapi3/client/petstore/ruby/docs/ArrayOfNumberOnly.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **array_number** | **Array<Float>** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::ArrayOfNumberOnly.new(array_number: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/ArrayTest.md b/samples/openapi3/client/petstore/ruby/docs/ArrayTest.md index 5fbfd67159b..f84b9c549b1 100644 --- a/samples/openapi3/client/petstore/ruby/docs/ArrayTest.md +++ b/samples/openapi3/client/petstore/ruby/docs/ArrayTest.md @@ -7,4 +7,14 @@ Name | Type | Description | Notes **array_array_of_integer** | **Array<Array<Integer>>** | | [optional] **array_array_of_model** | **Array<Array<ReadOnlyFirst>>** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::ArrayTest.new(array_of_string: null, + array_array_of_integer: null, + array_array_of_model: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/Capitalization.md b/samples/openapi3/client/petstore/ruby/docs/Capitalization.md index d99c603f54a..18f0a7bf9a2 100644 --- a/samples/openapi3/client/petstore/ruby/docs/Capitalization.md +++ b/samples/openapi3/client/petstore/ruby/docs/Capitalization.md @@ -10,4 +10,17 @@ Name | Type | Description | Notes **sca_eth_flow_points** | **String** | | [optional] **att_name** | **String** | Name of the pet | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Capitalization.new(small_camel: null, + capital_camel: null, + small_snake: null, + capital_snake: null, + sca_eth_flow_points: null, + att_name: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/Cat.md b/samples/openapi3/client/petstore/ruby/docs/Cat.md index 6abb9e1a348..5b008c6d831 100644 --- a/samples/openapi3/client/petstore/ruby/docs/Cat.md +++ b/samples/openapi3/client/petstore/ruby/docs/Cat.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **declawed** | **BOOLEAN** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Cat.new(declawed: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/Category.md b/samples/openapi3/client/petstore/ruby/docs/Category.md index 4500de105b2..d785404ed10 100644 --- a/samples/openapi3/client/petstore/ruby/docs/Category.md +++ b/samples/openapi3/client/petstore/ruby/docs/Category.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **id** | **Integer** | | [optional] **name** | **String** | | [default to 'default-name'] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Category.new(id: null, + name: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/ClassModel.md b/samples/openapi3/client/petstore/ruby/docs/ClassModel.md index cd4de850633..82243bd4f30 100644 --- a/samples/openapi3/client/petstore/ruby/docs/ClassModel.md +++ b/samples/openapi3/client/petstore/ruby/docs/ClassModel.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **_class** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::ClassModel.new(_class: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/Client.md b/samples/openapi3/client/petstore/ruby/docs/Client.md index 2b8e400aaee..639e19ad845 100644 --- a/samples/openapi3/client/petstore/ruby/docs/Client.md +++ b/samples/openapi3/client/petstore/ruby/docs/Client.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **client** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Client.new(client: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/Dog.md b/samples/openapi3/client/petstore/ruby/docs/Dog.md index 2b8d2281a12..0164e509045 100644 --- a/samples/openapi3/client/petstore/ruby/docs/Dog.md +++ b/samples/openapi3/client/petstore/ruby/docs/Dog.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **breed** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Dog.new(breed: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/EnumArrays.md b/samples/openapi3/client/petstore/ruby/docs/EnumArrays.md index ef6a935fbd7..a1de1ae2dba 100644 --- a/samples/openapi3/client/petstore/ruby/docs/EnumArrays.md +++ b/samples/openapi3/client/petstore/ruby/docs/EnumArrays.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **just_symbol** | **String** | | [optional] **array_enum** | **Array<String>** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::EnumArrays.new(just_symbol: null, + array_enum: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/EnumClass.md b/samples/openapi3/client/petstore/ruby/docs/EnumClass.md index 8d56e1f8873..0b71f09733e 100644 --- a/samples/openapi3/client/petstore/ruby/docs/EnumClass.md +++ b/samples/openapi3/client/petstore/ruby/docs/EnumClass.md @@ -4,4 +4,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::EnumClass.new() +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/EnumTest.md b/samples/openapi3/client/petstore/ruby/docs/EnumTest.md index 87297ac476e..d6025032df4 100644 --- a/samples/openapi3/client/petstore/ruby/docs/EnumTest.md +++ b/samples/openapi3/client/petstore/ruby/docs/EnumTest.md @@ -9,4 +9,16 @@ Name | Type | Description | Notes **enum_number** | **Float** | | [optional] **outer_enum** | [**OuterEnum**](OuterEnum.md) | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::EnumTest.new(enum_string: null, + enum_string_required: null, + enum_integer: null, + enum_number: null, + outer_enum: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/File.md b/samples/openapi3/client/petstore/ruby/docs/File.md index 428a5a04188..2f2b8aaf748 100644 --- a/samples/openapi3/client/petstore/ruby/docs/File.md +++ b/samples/openapi3/client/petstore/ruby/docs/File.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **source_uri** | **String** | Test capitalization | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::File.new(source_uri: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/FileSchemaTestClass.md b/samples/openapi3/client/petstore/ruby/docs/FileSchemaTestClass.md index d32819b3578..29c3aac8c56 100644 --- a/samples/openapi3/client/petstore/ruby/docs/FileSchemaTestClass.md +++ b/samples/openapi3/client/petstore/ruby/docs/FileSchemaTestClass.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **file** | **File** | | [optional] **files** | **Array<File>** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::FileSchemaTestClass.new(file: null, + files: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/Foo.md b/samples/openapi3/client/petstore/ruby/docs/Foo.md index 3dd099f1593..1edcb1c7fec 100644 --- a/samples/openapi3/client/petstore/ruby/docs/Foo.md +++ b/samples/openapi3/client/petstore/ruby/docs/Foo.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **bar** | **String** | | [optional] [default to 'bar'] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Foo.new(bar: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/FormatTest.md b/samples/openapi3/client/petstore/ruby/docs/FormatTest.md index 8682ea539e8..3bae49bc7dc 100644 --- a/samples/openapi3/client/petstore/ruby/docs/FormatTest.md +++ b/samples/openapi3/client/petstore/ruby/docs/FormatTest.md @@ -19,4 +19,26 @@ Name | Type | Description | Notes **pattern_with_digits** | **String** | A string that is a 10 digit number. Can have leading zeros. | [optional] **pattern_with_digits_and_delimiter** | **String** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::FormatTest.new(integer: null, + int32: null, + int64: null, + number: null, + float: null, + double: null, + string: null, + byte: null, + binary: null, + date: null, + date_time: null, + uuid: 72f98069-206d-4f12-9f12-3d1e525a8e84, + password: null, + pattern_with_digits: null, + pattern_with_digits_and_delimiter: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/HasOnlyReadOnly.md b/samples/openapi3/client/petstore/ruby/docs/HasOnlyReadOnly.md index 16de3c060cc..b86538fb1d0 100644 --- a/samples/openapi3/client/petstore/ruby/docs/HasOnlyReadOnly.md +++ b/samples/openapi3/client/petstore/ruby/docs/HasOnlyReadOnly.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **bar** | **String** | | [optional] **foo** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::HasOnlyReadOnly.new(bar: null, + foo: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/HealthCheckResult.md b/samples/openapi3/client/petstore/ruby/docs/HealthCheckResult.md index 07d74e293b0..ca3bcb5f70d 100644 --- a/samples/openapi3/client/petstore/ruby/docs/HealthCheckResult.md +++ b/samples/openapi3/client/petstore/ruby/docs/HealthCheckResult.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **nullable_message** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::HealthCheckResult.new(nullable_message: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/InlineResponseDefault.md b/samples/openapi3/client/petstore/ruby/docs/InlineResponseDefault.md index 96b4ac89b74..59fab9ba2a1 100644 --- a/samples/openapi3/client/petstore/ruby/docs/InlineResponseDefault.md +++ b/samples/openapi3/client/petstore/ruby/docs/InlineResponseDefault.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **string** | [**Foo**](Foo.md) | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::InlineResponseDefault.new(string: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/List.md b/samples/openapi3/client/petstore/ruby/docs/List.md index 211d299f671..9e577145bbd 100644 --- a/samples/openapi3/client/petstore/ruby/docs/List.md +++ b/samples/openapi3/client/petstore/ruby/docs/List.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **_123_list** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::List.new(_123_list: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/MapTest.md b/samples/openapi3/client/petstore/ruby/docs/MapTest.md index 54e16e1933e..e8ff385a544 100644 --- a/samples/openapi3/client/petstore/ruby/docs/MapTest.md +++ b/samples/openapi3/client/petstore/ruby/docs/MapTest.md @@ -8,4 +8,15 @@ Name | Type | Description | Notes **direct_map** | **Hash<String, BOOLEAN>** | | [optional] **indirect_map** | **Hash<String, BOOLEAN>** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::MapTest.new(map_map_of_string: null, + map_of_enum_string: null, + direct_map: null, + indirect_map: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/openapi3/client/petstore/ruby/docs/MixedPropertiesAndAdditionalPropertiesClass.md index dcb02e2ffa6..5c7f0accb58 100644 --- a/samples/openapi3/client/petstore/ruby/docs/MixedPropertiesAndAdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/ruby/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -7,4 +7,14 @@ Name | Type | Description | Notes **date_time** | **DateTime** | | [optional] **map** | [**Hash<String, Animal>**](Animal.md) | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::MixedPropertiesAndAdditionalPropertiesClass.new(uuid: null, + date_time: null, + map: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/Model200Response.md b/samples/openapi3/client/petstore/ruby/docs/Model200Response.md index e745da1a756..94aa48f0818 100644 --- a/samples/openapi3/client/petstore/ruby/docs/Model200Response.md +++ b/samples/openapi3/client/petstore/ruby/docs/Model200Response.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **name** | **Integer** | | [optional] **_class** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Model200Response.new(name: null, + _class: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/ModelReturn.md b/samples/openapi3/client/petstore/ruby/docs/ModelReturn.md index dfcfff1dd06..193e2eb4da8 100644 --- a/samples/openapi3/client/petstore/ruby/docs/ModelReturn.md +++ b/samples/openapi3/client/petstore/ruby/docs/ModelReturn.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **_return** | **Integer** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::ModelReturn.new(_return: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/Name.md b/samples/openapi3/client/petstore/ruby/docs/Name.md index 1ae49f8ee1b..575b9f1585f 100644 --- a/samples/openapi3/client/petstore/ruby/docs/Name.md +++ b/samples/openapi3/client/petstore/ruby/docs/Name.md @@ -8,4 +8,15 @@ Name | Type | Description | Notes **property** | **String** | | [optional] **_123_number** | **Integer** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Name.new(name: null, + snake_case: null, + property: null, + _123_number: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/NumberOnly.md b/samples/openapi3/client/petstore/ruby/docs/NumberOnly.md index 4be8a12a79d..c12410c8c86 100644 --- a/samples/openapi3/client/petstore/ruby/docs/NumberOnly.md +++ b/samples/openapi3/client/petstore/ruby/docs/NumberOnly.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **just_number** | **Float** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::NumberOnly.new(just_number: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/Order.md b/samples/openapi3/client/petstore/ruby/docs/Order.md index 52a832c5106..70a1d3d92f8 100644 --- a/samples/openapi3/client/petstore/ruby/docs/Order.md +++ b/samples/openapi3/client/petstore/ruby/docs/Order.md @@ -10,4 +10,17 @@ Name | Type | Description | Notes **status** | **String** | Order Status | [optional] **complete** | **BOOLEAN** | | [optional] [default to false] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Order.new(id: null, + pet_id: null, + quantity: null, + ship_date: null, + status: null, + complete: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/OuterComposite.md b/samples/openapi3/client/petstore/ruby/docs/OuterComposite.md index e1548870a7b..a93fef0ee57 100644 --- a/samples/openapi3/client/petstore/ruby/docs/OuterComposite.md +++ b/samples/openapi3/client/petstore/ruby/docs/OuterComposite.md @@ -7,4 +7,14 @@ Name | Type | Description | Notes **my_string** | **String** | | [optional] **my_boolean** | **BOOLEAN** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::OuterComposite.new(my_number: null, + my_string: null, + my_boolean: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/OuterEnum.md b/samples/openapi3/client/petstore/ruby/docs/OuterEnum.md index 60d87c12381..3c63edf54a5 100644 --- a/samples/openapi3/client/petstore/ruby/docs/OuterEnum.md +++ b/samples/openapi3/client/petstore/ruby/docs/OuterEnum.md @@ -4,4 +4,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::OuterEnum.new() +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/Pet.md b/samples/openapi3/client/petstore/ruby/docs/Pet.md index f4320a0b72b..49318999bd1 100644 --- a/samples/openapi3/client/petstore/ruby/docs/Pet.md +++ b/samples/openapi3/client/petstore/ruby/docs/Pet.md @@ -10,4 +10,17 @@ Name | Type | Description | Notes **tags** | [**Array<Tag>**](Tag.md) | | [optional] **status** | **String** | pet status in the store | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Pet.new(id: null, + category: null, + name: doggie, + photo_urls: null, + tags: null, + status: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/ReadOnlyFirst.md b/samples/openapi3/client/petstore/ruby/docs/ReadOnlyFirst.md index e49b5119478..8d0bf7ab923 100644 --- a/samples/openapi3/client/petstore/ruby/docs/ReadOnlyFirst.md +++ b/samples/openapi3/client/petstore/ruby/docs/ReadOnlyFirst.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **bar** | **String** | | [optional] **baz** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::ReadOnlyFirst.new(bar: null, + baz: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/SpecialModelName.md b/samples/openapi3/client/petstore/ruby/docs/SpecialModelName.md index 581ab6907ef..753a6ea26bf 100644 --- a/samples/openapi3/client/petstore/ruby/docs/SpecialModelName.md +++ b/samples/openapi3/client/petstore/ruby/docs/SpecialModelName.md @@ -5,4 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **special_property_name** | **Integer** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::SpecialModelName.new(special_property_name: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/Tag.md b/samples/openapi3/client/petstore/ruby/docs/Tag.md index 5bd94d6c04e..717fe6469c4 100644 --- a/samples/openapi3/client/petstore/ruby/docs/Tag.md +++ b/samples/openapi3/client/petstore/ruby/docs/Tag.md @@ -6,4 +6,13 @@ Name | Type | Description | Notes **id** | **Integer** | | [optional] **name** | **String** | | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::Tag.new(id: null, + name: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/docs/User.md b/samples/openapi3/client/petstore/ruby/docs/User.md index bd76116e023..25df1a9a218 100644 --- a/samples/openapi3/client/petstore/ruby/docs/User.md +++ b/samples/openapi3/client/petstore/ruby/docs/User.md @@ -12,4 +12,19 @@ Name | Type | Description | Notes **phone** | **String** | | [optional] **user_status** | **Integer** | User Status | [optional] +## Code Sample + +```ruby +require 'Petstore' + +instance = Petstore::User.new(id: null, + username: null, + first_name: null, + last_name: null, + email: null, + password: null, + phone: null, + user_status: null) +``` + diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/api_error.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/api_error.rb index 66bf1edb437..fdef5a7fd20 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/api_error.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/api_error.rb @@ -34,5 +34,24 @@ module Petstore super arg end end + + # Override to_s to display a friendly error message + def to_s + message + end + + def message + if @message.nil? + msg = "Error message: the server returns an error" + else + msg = @message + end + + msg += "\nHTTP status code: #{code}" if code + msg += "\nResponse headers: #{response_headers}" if response_headers + msg += "\nResponse body: #{response_body}" if response_body + + msg + end end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb index 677fcc53190..b7605329f76 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb @@ -37,18 +37,25 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::AdditionalPropertiesClass` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::AdditionalPropertiesClass`. 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.has_key?(:'map_property') + if attributes.key?(:'map_property') if (value = attributes[:'map_property']).is_a?(Hash) self.map_property = value end end - if attributes.has_key?(:'map_of_map_property') + if attributes.key?(:'map_of_map_property') if (value = attributes[:'map_of_map_property']).is_a?(Hash) self.map_of_map_property = value end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb index cf332acd704..34a5173da3f 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb @@ -42,16 +42,23 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) - - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } - - if attributes.has_key?(:'className') - self.class_name = attributes[:'className'] + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Animal` initialize method" end - if attributes.has_key?(:'color') + # 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::Animal`. 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?(:'class_name') + self.class_name = attributes[:'class_name'] + end + + if attributes.key?(:'color') self.color = attributes[:'color'] else self.color = 'red' diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb index b9bf69a9e9e..54183e3e782 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -41,20 +41,27 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ApiResponse` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::ApiResponse`. 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.has_key?(:'code') + if attributes.key?(:'code') self.code = attributes[:'code'] end - if attributes.has_key?(:'type') + if attributes.key?(:'type') self.type = attributes[:'type'] end - if attributes.has_key?(:'message') + if attributes.key?(:'message') self.message = attributes[:'message'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb index 8ffa47da6a6..cb7cd570949 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb @@ -33,13 +33,20 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ArrayOfArrayOfNumberOnly` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::ArrayOfArrayOfNumberOnly`. 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.has_key?(:'ArrayArrayNumber') - if (value = attributes[:'ArrayArrayNumber']).is_a?(Array) + if attributes.key?(:'array_array_number') + if (value = attributes[:'array_array_number']).is_a?(Array) self.array_array_number = value end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb index dc737f6a7f6..9a1af59a50e 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb @@ -33,13 +33,20 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ArrayOfNumberOnly` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::ArrayOfNumberOnly`. 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.has_key?(:'ArrayNumber') - if (value = attributes[:'ArrayNumber']).is_a?(Array) + if attributes.key?(:'array_number') + if (value = attributes[:'array_number']).is_a?(Array) self.array_number = value end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb index 067eca1ca86..03de89bc69d 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb @@ -41,24 +41,31 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ArrayTest` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::ArrayTest`. 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.has_key?(:'array_of_string') + if attributes.key?(:'array_of_string') if (value = attributes[:'array_of_string']).is_a?(Array) self.array_of_string = value end end - if attributes.has_key?(:'array_array_of_integer') + if attributes.key?(:'array_array_of_integer') if (value = attributes[:'array_array_of_integer']).is_a?(Array) self.array_array_of_integer = value end end - if attributes.has_key?(:'array_array_of_model') + if attributes.key?(:'array_array_of_model') if (value = attributes[:'array_array_of_model']).is_a?(Array) self.array_array_of_model = value end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb index fe0eac256d7..7c2480f0378 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb @@ -54,33 +54,40 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) - - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } - - if attributes.has_key?(:'smallCamel') - self.small_camel = attributes[:'smallCamel'] + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Capitalization` initialize method" end - if attributes.has_key?(:'CapitalCamel') - self.capital_camel = attributes[:'CapitalCamel'] + # 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::Capitalization`. 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?(:'small_camel') + self.small_camel = attributes[:'small_camel'] end - if attributes.has_key?(:'small_Snake') - self.small_snake = attributes[:'small_Snake'] + if attributes.key?(:'capital_camel') + self.capital_camel = attributes[:'capital_camel'] end - if attributes.has_key?(:'Capital_Snake') - self.capital_snake = attributes[:'Capital_Snake'] + if attributes.key?(:'small_snake') + self.small_snake = attributes[:'small_snake'] end - if attributes.has_key?(:'SCA_ETH_Flow_Points') - self.sca_eth_flow_points = attributes[:'SCA_ETH_Flow_Points'] + if attributes.key?(:'capital_snake') + self.capital_snake = attributes[:'capital_snake'] end - if attributes.has_key?(:'ATT_NAME') - self.att_name = attributes[:'ATT_NAME'] + if attributes.key?(:'sca_eth_flow_points') + self.sca_eth_flow_points = attributes[:'sca_eth_flow_points'] + end + + if attributes.key?(:'att_name') + self.att_name = attributes[:'att_name'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb index ea7b6ab023c..fc126f6d4f1 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb @@ -40,15 +40,22 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Cat` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Cat`. 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 + } # call parent's initialize super(attributes) - if attributes.has_key?(:'declawed') + if attributes.key?(:'declawed') self.declawed = attributes[:'declawed'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb index 7e6972989d5..766999435ad 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb @@ -37,16 +37,23 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Category` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Category`. 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.has_key?(:'id') + if attributes.key?(:'id') self.id = attributes[:'id'] end - if attributes.has_key?(:'name') + if attributes.key?(:'name') self.name = attributes[:'name'] else self.name = 'default-name' diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb index 3864b48b8d2..70f888627a4 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb @@ -34,12 +34,19 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ClassModel` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::ClassModel`. 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.has_key?(:'_class') + if attributes.key?(:'_class') self._class = attributes[:'_class'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb index cb67fe62a36..df4a65ed366 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb @@ -33,12 +33,19 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Client` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Client`. 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.has_key?(:'client') + if attributes.key?(:'client') self.client = attributes[:'client'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb index 82c9b239926..55351bc099d 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb @@ -40,15 +40,22 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Dog` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Dog`. 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 + } # call parent's initialize super(attributes) - if attributes.has_key?(:'breed') + if attributes.key?(:'breed') self.breed = attributes[:'breed'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb index 6c21580387d..ada854d6f84 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb @@ -59,16 +59,23 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::EnumArrays` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::EnumArrays`. 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.has_key?(:'just_symbol') + if attributes.key?(:'just_symbol') self.just_symbol = attributes[:'just_symbol'] end - if attributes.has_key?(:'array_enum') + if attributes.key?(:'array_enum') if (value = attributes[:'array_enum']).is_a?(Array) self.array_enum = value end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb index 89870ae722b..2b0634fc36e 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb @@ -71,29 +71,36 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::EnumTest` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::EnumTest`. 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.has_key?(:'enum_string') + if attributes.key?(:'enum_string') self.enum_string = attributes[:'enum_string'] end - if attributes.has_key?(:'enum_string_required') + if attributes.key?(:'enum_string_required') self.enum_string_required = attributes[:'enum_string_required'] end - if attributes.has_key?(:'enum_integer') + if attributes.key?(:'enum_integer') self.enum_integer = attributes[:'enum_integer'] end - if attributes.has_key?(:'enum_number') + if attributes.key?(:'enum_number') self.enum_number = attributes[:'enum_number'] end - if attributes.has_key?(:'outerEnum') - self.outer_enum = attributes[:'outerEnum'] + if attributes.key?(:'outer_enum') + self.outer_enum = attributes[:'outer_enum'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb index 2b91d719ecf..54ce33ac5ba 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb @@ -35,13 +35,20 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::File` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::File`. 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.has_key?(:'sourceURI') - self.source_uri = attributes[:'sourceURI'] + if attributes.key?(:'source_uri') + self.source_uri = attributes[:'source_uri'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb index 1c10ff41fb6..ef038a50e8e 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb @@ -37,16 +37,23 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::FileSchemaTestClass` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::FileSchemaTestClass`. 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.has_key?(:'file') + if attributes.key?(:'file') self.file = attributes[:'file'] end - if attributes.has_key?(:'files') + if attributes.key?(:'files') if (value = attributes[:'files']).is_a?(Array) self.files = value end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/foo.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/foo.rb index b73464b0084..3c591303da2 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/foo.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/foo.rb @@ -33,12 +33,19 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Foo` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Foo`. 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.has_key?(:'bar') + if attributes.key?(:'bar') self.bar = attributes[:'bar'] else self.bar = 'bar' diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb index 325ca65ddc4..ee05d376464 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -91,68 +91,75 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::FormatTest` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::FormatTest`. 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.has_key?(:'integer') + if attributes.key?(:'integer') self.integer = attributes[:'integer'] end - if attributes.has_key?(:'int32') + if attributes.key?(:'int32') self.int32 = attributes[:'int32'] end - if attributes.has_key?(:'int64') + if attributes.key?(:'int64') self.int64 = attributes[:'int64'] end - if attributes.has_key?(:'number') + if attributes.key?(:'number') self.number = attributes[:'number'] end - if attributes.has_key?(:'float') + if attributes.key?(:'float') self.float = attributes[:'float'] end - if attributes.has_key?(:'double') + if attributes.key?(:'double') self.double = attributes[:'double'] end - if attributes.has_key?(:'string') + if attributes.key?(:'string') self.string = attributes[:'string'] end - if attributes.has_key?(:'byte') + if attributes.key?(:'byte') self.byte = attributes[:'byte'] end - if attributes.has_key?(:'binary') + if attributes.key?(:'binary') self.binary = attributes[:'binary'] end - if attributes.has_key?(:'date') + if attributes.key?(:'date') self.date = attributes[:'date'] end - if attributes.has_key?(:'dateTime') - self.date_time = attributes[:'dateTime'] + if attributes.key?(:'date_time') + self.date_time = attributes[:'date_time'] end - if attributes.has_key?(:'uuid') + if attributes.key?(:'uuid') self.uuid = attributes[:'uuid'] end - if attributes.has_key?(:'password') + if attributes.key?(:'password') self.password = attributes[:'password'] end - if attributes.has_key?(:'pattern_with_digits') + if attributes.key?(:'pattern_with_digits') self.pattern_with_digits = attributes[:'pattern_with_digits'] end - if attributes.has_key?(:'pattern_with_digits_and_delimiter') + if attributes.key?(:'pattern_with_digits_and_delimiter') self.pattern_with_digits_and_delimiter = attributes[:'pattern_with_digits_and_delimiter'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb index 84d61b08c71..65f6afd90f6 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb @@ -37,16 +37,23 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::HasOnlyReadOnly` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::HasOnlyReadOnly`. 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.has_key?(:'bar') + if attributes.key?(:'bar') self.bar = attributes[:'bar'] end - if attributes.has_key?(:'foo') + if attributes.key?(:'foo') self.foo = attributes[:'foo'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/health_check_result.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/health_check_result.rb index c635faeaf03..518da4e19ac 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/health_check_result.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/health_check_result.rb @@ -34,13 +34,20 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::HealthCheckResult` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::HealthCheckResult`. 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.has_key?(:'NullableMessage') - self.nullable_message = attributes[:'NullableMessage'] + if attributes.key?(:'nullable_message') + self.nullable_message = attributes[:'nullable_message'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_response_default.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_response_default.rb index 8647f14c508..30e20c2bc2b 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_response_default.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_response_default.rb @@ -33,12 +33,19 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineResponseDefault` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::InlineResponseDefault`. 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.has_key?(:'string') + if attributes.key?(:'string') self.string = attributes[:'string'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb index 0155981d0d4..0d3e43c0b09 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb @@ -33,13 +33,20 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::List` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::List`. 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.has_key?(:'123-list') - self._123_list = attributes[:'123-list'] + if attributes.key?(:'_123_list') + self._123_list = attributes[:'_123_list'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb index d8e5b805a9a..9c4fc30dabb 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb @@ -67,30 +67,37 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::MapTest` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::MapTest`. 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.has_key?(:'map_map_of_string') + if attributes.key?(:'map_map_of_string') if (value = attributes[:'map_map_of_string']).is_a?(Hash) self.map_map_of_string = value end end - if attributes.has_key?(:'map_of_enum_string') + if attributes.key?(:'map_of_enum_string') if (value = attributes[:'map_of_enum_string']).is_a?(Hash) self.map_of_enum_string = value end end - if attributes.has_key?(:'direct_map') + if attributes.key?(:'direct_map') if (value = attributes[:'direct_map']).is_a?(Hash) self.direct_map = value end end - if attributes.has_key?(:'indirect_map') + if attributes.key?(:'indirect_map') if (value = attributes[:'indirect_map']).is_a?(Hash) self.indirect_map = value end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb index 1a8f783bcc2..ef0e1419137 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -41,20 +41,27 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::MixedPropertiesAndAdditionalPropertiesClass` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::MixedPropertiesAndAdditionalPropertiesClass`. 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.has_key?(:'uuid') + if attributes.key?(:'uuid') self.uuid = attributes[:'uuid'] end - if attributes.has_key?(:'dateTime') - self.date_time = attributes[:'dateTime'] + if attributes.key?(:'date_time') + self.date_time = attributes[:'date_time'] end - if attributes.has_key?(:'map') + if attributes.key?(:'map') if (value = attributes[:'map']).is_a?(Hash) self.map = value end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb index c07c547f072..70914ae80c3 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb @@ -38,17 +38,24 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Model200Response` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Model200Response`. 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.has_key?(:'name') + if attributes.key?(:'name') self.name = attributes[:'name'] end - if attributes.has_key?(:'class') - self._class = attributes[:'class'] + if attributes.key?(:'_class') + self._class = attributes[:'_class'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb index 3311456698e..a261b73ffef 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -34,13 +34,20 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ModelReturn` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::ModelReturn`. 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.has_key?(:'return') - self._return = attributes[:'return'] + if attributes.key?(:'_return') + self._return = attributes[:'_return'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb index c7e2bea5a9c..cdb941cd20d 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb @@ -46,25 +46,32 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Name` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Name`. 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.has_key?(:'name') + if attributes.key?(:'name') self.name = attributes[:'name'] end - if attributes.has_key?(:'snake_case') + if attributes.key?(:'snake_case') self.snake_case = attributes[:'snake_case'] end - if attributes.has_key?(:'property') + if attributes.key?(:'property') self.property = attributes[:'property'] end - if attributes.has_key?(:'123Number') - self._123_number = attributes[:'123Number'] + if attributes.key?(:'_123_number') + self._123_number = attributes[:'_123_number'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb index 9ea2e5d2b2b..e3e512cde73 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb @@ -33,13 +33,20 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::NumberOnly` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::NumberOnly`. 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.has_key?(:'JustNumber') - self.just_number = attributes[:'JustNumber'] + if attributes.key?(:'just_number') + self.just_number = attributes[:'just_number'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb index c9254d8ef61..4d2118ee095 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb @@ -76,32 +76,39 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Order` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Order`. 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.has_key?(:'id') + if attributes.key?(:'id') self.id = attributes[:'id'] end - if attributes.has_key?(:'petId') - self.pet_id = attributes[:'petId'] + if attributes.key?(:'pet_id') + self.pet_id = attributes[:'pet_id'] end - if attributes.has_key?(:'quantity') + if attributes.key?(:'quantity') self.quantity = attributes[:'quantity'] end - if attributes.has_key?(:'shipDate') - self.ship_date = attributes[:'shipDate'] + if attributes.key?(:'ship_date') + self.ship_date = attributes[:'ship_date'] end - if attributes.has_key?(:'status') + if attributes.key?(:'status') self.status = attributes[:'status'] end - if attributes.has_key?(:'complete') + if attributes.key?(:'complete') self.complete = attributes[:'complete'] else self.complete = false diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb index b42c8ad462d..d7dc16af69a 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb @@ -41,20 +41,27 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::OuterComposite` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::OuterComposite`. 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.has_key?(:'my_number') + if attributes.key?(:'my_number') self.my_number = attributes[:'my_number'] end - if attributes.has_key?(:'my_string') + if attributes.key?(:'my_string') self.my_string = attributes[:'my_string'] end - if attributes.has_key?(:'my_boolean') + if attributes.key?(:'my_boolean') self.my_boolean = attributes[:'my_boolean'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb index a2fd3bd5b8b..7bf0672af3c 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb @@ -76,36 +76,43 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Pet` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Pet`. 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.has_key?(:'id') + if attributes.key?(:'id') self.id = attributes[:'id'] end - if attributes.has_key?(:'category') + if attributes.key?(:'category') self.category = attributes[:'category'] end - if attributes.has_key?(:'name') + if attributes.key?(:'name') self.name = attributes[:'name'] end - if attributes.has_key?(:'photoUrls') - if (value = attributes[:'photoUrls']).is_a?(Array) + if attributes.key?(:'photo_urls') + if (value = attributes[:'photo_urls']).is_a?(Array) self.photo_urls = value end end - if attributes.has_key?(:'tags') + if attributes.key?(:'tags') if (value = attributes[:'tags']).is_a?(Array) self.tags = value end end - if attributes.has_key?(:'status') + if attributes.key?(:'status') self.status = attributes[:'status'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb index 350e66716af..b2fa0e4374d 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb @@ -37,16 +37,23 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ReadOnlyFirst` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::ReadOnlyFirst`. 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.has_key?(:'bar') + if attributes.key?(:'bar') self.bar = attributes[:'bar'] end - if attributes.has_key?(:'baz') + if attributes.key?(:'baz') self.baz = attributes[:'baz'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb index ad676f4bfcb..960713915f6 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb @@ -33,13 +33,20 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::SpecialModelName` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::SpecialModelName`. 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.has_key?(:'$special[property.name]') - self.special_property_name = attributes[:'$special[property.name]'] + if attributes.key?(:'special_property_name') + self.special_property_name = attributes[:'special_property_name'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb index f15575379ea..2b8ae4e2505 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb @@ -37,16 +37,23 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Tag` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::Tag`. 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.has_key?(:'id') + if attributes.key?(:'id') self.id = attributes[:'id'] end - if attributes.has_key?(:'name') + if attributes.key?(:'name') self.name = attributes[:'name'] end end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb index e4138a400f1..365ad8a0757 100644 --- a/samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb @@ -62,41 +62,48 @@ module Petstore # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) - return unless attributes.is_a?(Hash) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::User` initialize method" + end - # convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + # 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::User`. 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.has_key?(:'id') + if attributes.key?(:'id') self.id = attributes[:'id'] end - if attributes.has_key?(:'username') + if attributes.key?(:'username') self.username = attributes[:'username'] end - if attributes.has_key?(:'firstName') - self.first_name = attributes[:'firstName'] + if attributes.key?(:'first_name') + self.first_name = attributes[:'first_name'] end - if attributes.has_key?(:'lastName') - self.last_name = attributes[:'lastName'] + if attributes.key?(:'last_name') + self.last_name = attributes[:'last_name'] end - if attributes.has_key?(:'email') + if attributes.key?(:'email') self.email = attributes[:'email'] end - if attributes.has_key?(:'password') + if attributes.key?(:'password') self.password = attributes[:'password'] end - if attributes.has_key?(:'phone') + if attributes.key?(:'phone') self.phone = attributes[:'phone'] end - if attributes.has_key?(:'userStatus') - self.user_status = attributes[:'userStatus'] + if attributes.key?(:'user_status') + self.user_status = attributes[:'user_status'] end end diff --git a/samples/openapi3/client/petstore/ruby/spec/custom/api_error_spec.rb b/samples/openapi3/client/petstore/ruby/spec/custom/api_error_spec.rb index 7790ae3c6ba..46b86b1a250 100644 --- a/samples/openapi3/client/petstore/ruby/spec/custom/api_error_spec.rb +++ b/samples/openapi3/client/petstore/ruby/spec/custom/api_error_spec.rb @@ -7,9 +7,14 @@ describe Petstore::ApiClient do expect(err.message).to eq("Hello") end + it "should save the message and code if both are given" do + err = Petstore::ApiError.new(message: "Hello", code: 0) + expect(err.message).to eq("Hello\nHTTP status code: 0") + end + it "should save the hash as message if no message is given" do err = Petstore::ApiError.new(code: 500, response_body: "server error") - expect(err.message).to eq("{:code=>500, :response_body=>\"server error\"}") + expect(err.message).to eq("Error message: the server returns an error\nHTTP status code: 500\nResponse body: server error") end end end diff --git a/samples/openapi3/client/petstore/ruby/spec/custom/pet_spec.rb b/samples/openapi3/client/petstore/ruby/spec/custom/pet_spec.rb index 266f3dcb7cb..c56be964a2f 100644 --- a/samples/openapi3/client/petstore/ruby/spec/custom/pet_spec.rb +++ b/samples/openapi3/client/petstore/ruby/spec/custom/pet_spec.rb @@ -78,7 +78,8 @@ describe "Pet" do fail 'it should raise error' rescue Petstore::ApiError => e expect(e.code).to eq(404) - expect(e.message).to eq('Not Found') + # skip the check as the response contains a timestamp that changes on every reponse + #expect(e.message).to eq("Error message: the server returns an error\nHTTP status code: 404\nResponse headers: {\"Date\"=>\"Tue, 26 Feb 2019 04:35:40 GMT\", \"Access-Control-Allow-Origin\"=>\"*\", \"Access-Control-Allow-Methods\"=>\"GET, POST, DELETE, PUT\", \"Access-Control-Allow-Headers\"=>\"Content-Type, api_key, Authorization\", \"Content-Type\"=>\"application/json\", \"Connection\"=>\"close\", \"Server\"=>\"Jetty(9.2.9.v20150224)\"}\nResponse body: {\"code\":1,\"type\":\"error\",\"message\":\"Pet not found\"}") expect(e.response_body).to eq('{"code":1,"type":"error","message":"Pet not found"}') expect(e.response_headers).to include('Content-Type') expect(e.response_headers['Content-Type']).to eq('application/json') diff --git a/samples/openapi3/client/petstore/ruby/spec/petstore_helper.rb b/samples/openapi3/client/petstore/ruby/spec/petstore_helper.rb index 9510a2c3aff..96b0711cec5 100644 --- a/samples/openapi3/client/petstore/ruby/spec/petstore_helper.rb +++ b/samples/openapi3/client/petstore/ruby/spec/petstore_helper.rb @@ -24,9 +24,9 @@ end def prepare_store(store_api) order_id = 5 order = Petstore::Order.new("id" => order_id, - "petId" => 123, + "pet_id" => 123, "quantity" => 789, - "shipDate" => "2015-04-06T23:42:01.678Z", + "ship_date" => "2015-04-06T23:42:01.678Z", "status" => "placed", "complete" => false) store_api.place_order(order)