Fix ruby model boolean attributes

This commit is contained in:
Brian Hou 2016-04-26 10:21:16 -07:00
parent 07d2374320
commit 1361bb7c0b
17 changed files with 61 additions and 53 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 }