diff --git a/modules/swagger-codegen/src/main/resources/ruby/model.mustache b/modules/swagger-codegen/src/main/resources/ruby/model.mustache index b95b55bcee9..14f26898d2b 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/model.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/model.mustache @@ -38,7 +38,7 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} {{#vars}} - if attributes[:'{{{baseName}}}'] + if attributes.has_key?(:'{{{baseName}}}') {{#isContainer}} if (value = attributes[:'{{{baseName}}}']).is_a?(Array) self.{{{name}}} = value diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 9d9deefd9ee..cab06a92ce1 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-25T23:58:59.140+08:00 +- Build date: 2016-04-26T10:05:22.048-07:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index 2f26f9b4bb0..5612f227d09 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -42,7 +42,7 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'className'] + if attributes.has_key?(:'className') self.class_name = attributes[:'className'] end 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 da0418eda50..79da573e941 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -50,15 +50,15 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'code'] + if attributes.has_key?(:'code') self.code = attributes[:'code'] end - if attributes[:'type'] + if attributes.has_key?(:'type') self.type = attributes[:'type'] end - if attributes[:'message'] + if attributes.has_key?(:'message') self.message = attributes[:'message'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index 0f8c34f0896..12f17b85553 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -46,11 +46,11 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'className'] + if attributes.has_key?(:'className') self.class_name = attributes[:'className'] end - if attributes[:'declawed'] + if attributes.has_key?(:'declawed') self.declawed = attributes[:'declawed'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb index 33e4a539fb3..c4879d65bb4 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -46,11 +46,11 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] + if attributes.has_key?(:'id') self.id = attributes[:'id'] end - if attributes[:'name'] + if attributes.has_key?(:'name') self.name = attributes[:'name'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index 66fd396e753..90d213dbf45 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -46,11 +46,11 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'className'] + if attributes.has_key?(:'className') self.class_name = attributes[:'className'] end - if attributes[:'breed'] + if attributes.has_key?(:'breed') self.breed = attributes[:'breed'] 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 e4373bb955f..a7ebd095f9d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -86,51 +86,51 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'integer'] + if attributes.has_key?(:'integer') self.integer = attributes[:'integer'] end - if attributes[:'int32'] + if attributes.has_key?(:'int32') self.int32 = attributes[:'int32'] end - if attributes[:'int64'] + if attributes.has_key?(:'int64') self.int64 = attributes[:'int64'] end - if attributes[:'number'] + if attributes.has_key?(:'number') self.number = attributes[:'number'] end - if attributes[:'float'] + if attributes.has_key?(:'float') self.float = attributes[:'float'] end - if attributes[:'double'] + if attributes.has_key?(:'double') self.double = attributes[:'double'] end - if attributes[:'string'] + if attributes.has_key?(:'string') self.string = attributes[:'string'] end - if attributes[:'byte'] + if attributes.has_key?(:'byte') self.byte = attributes[:'byte'] end - if attributes[:'binary'] + if attributes.has_key?(:'binary') self.binary = attributes[:'binary'] end - if attributes[:'date'] + if attributes.has_key?(:'date') self.date = attributes[:'date'] end - if attributes[:'dateTime'] + if attributes.has_key?(:'dateTime') self.date_time = attributes[:'dateTime'] end - if attributes[:'password'] + if attributes.has_key?(:'password') self.password = attributes[:'password'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb index 71b4501d99e..7a2473fb8b9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb @@ -43,7 +43,7 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'name'] + if attributes.has_key?(:'name') self.name = attributes[:'name'] 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 bb015662bc4..0361451b290 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -43,7 +43,7 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'return'] + if attributes.has_key?(:'return') self._return = attributes[:'return'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index bec29f9c69e..d5e3ef4adb8 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -51,15 +51,15 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'name'] + if attributes.has_key?(:'name') self.name = attributes[:'name'] end - if attributes[:'snake_case'] + if attributes.has_key?(:'snake_case') self.snake_case = attributes[:'snake_case'] end - if attributes[:'property'] + if attributes.has_key?(:'property') self.property = attributes[:'property'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index b243b70cfb8..6c021e50ec7 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -63,27 +63,27 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] + if attributes.has_key?(:'id') self.id = attributes[:'id'] end - if attributes[:'petId'] + if attributes.has_key?(:'petId') self.pet_id = attributes[:'petId'] end - if attributes[:'quantity'] + if attributes.has_key?(:'quantity') self.quantity = attributes[:'quantity'] end - if attributes[:'shipDate'] + if attributes.has_key?(:'shipDate') self.ship_date = attributes[:'shipDate'] end - if attributes[:'status'] + if attributes.has_key?(:'status') self.status = attributes[:'status'] end - if attributes[:'complete'] + if attributes.has_key?(:'complete') self.complete = attributes[:'complete'] else self.complete = false diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index cdd312f1dad..ba4d466df21 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -63,31 +63,31 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] + if attributes.has_key?(:'id') self.id = attributes[:'id'] end - if attributes[:'category'] + if attributes.has_key?(:'category') self.category = attributes[:'category'] end - if attributes[:'name'] + if attributes.has_key?(:'name') self.name = attributes[:'name'] end - if attributes[:'photoUrls'] + if attributes.has_key?(:'photoUrls') if (value = attributes[:'photoUrls']).is_a?(Array) self.photo_urls = value end end - if attributes[:'tags'] + if attributes.has_key?(:'tags') if (value = attributes[:'tags']).is_a?(Array) self.tags = value end end - if attributes[:'status'] + if attributes.has_key?(:'status') self.status = attributes[:'status'] 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 94aa62981aa..853d1e49600 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 @@ -42,7 +42,7 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'$special[property.name]'] + if attributes.has_key?(:'$special[property.name]') self.special_property_name = attributes[:'$special[property.name]'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb index 3ef49f71eaa..d6d49068e37 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -46,11 +46,11 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] + if attributes.has_key?(:'id') self.id = attributes[:'id'] end - if attributes[:'name'] + if attributes.has_key?(:'name') self.name = attributes[:'name'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb index b9e7b91b08b..f0c39b741d5 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -71,35 +71,35 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] + if attributes.has_key?(:'id') self.id = attributes[:'id'] end - if attributes[:'username'] + if attributes.has_key?(:'username') self.username = attributes[:'username'] end - if attributes[:'firstName'] + if attributes.has_key?(:'firstName') self.first_name = attributes[:'firstName'] end - if attributes[:'lastName'] + if attributes.has_key?(:'lastName') self.last_name = attributes[:'lastName'] end - if attributes[:'email'] + if attributes.has_key?(:'email') self.email = attributes[:'email'] end - if attributes[:'password'] + if attributes.has_key?(:'password') self.password = attributes[:'password'] end - if attributes[:'phone'] + if attributes.has_key?(:'phone') self.phone = attributes[:'phone'] end - if attributes[:'userStatus'] + if attributes.has_key?(:'userStatus') self.user_status = attributes[:'userStatus'] end diff --git a/samples/client/petstore/ruby/spec/base_object_spec.rb b/samples/client/petstore/ruby/spec/base_object_spec.rb index 61dcb4d6d9d..a315d52276b 100644 --- a/samples/client/petstore/ruby/spec/base_object_spec.rb +++ b/samples/client/petstore/ruby/spec/base_object_spec.rb @@ -30,8 +30,16 @@ class ArrayMapObject < Petstore::Category end end - describe 'BaseObject' do + describe 'boolean values' do + let(:obj) { Petstore::Cat.new({declawed: false}) } + + it 'should have values set' do + obj.declawed.should_not eq nil + obj.declawed.should eq false + end + end + describe 'array and map properties' do let(:obj) { ArrayMapObject.new }