Merge pull request #2708 from PagerDuty/ruby-model-boolean-fix

Fix ruby model Boolean Attributes not being set
This commit is contained in:
wing328 2016-04-27 13:46:21 +08:00
commit 3289933405
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} attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
{{#vars}} {{#vars}}
if attributes[:'{{{baseName}}}'] if attributes.has_key?(:'{{{baseName}}}')
{{#isContainer}} {{#isContainer}}
if (value = attributes[:'{{{baseName}}}']).is_a?(Array) if (value = attributes[:'{{{baseName}}}']).is_a?(Array)
self.{{{name}}} = value 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 - API version: 1.0.0
- Package 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 - Build package: class io.swagger.codegen.languages.RubyClientCodegen
## Installation ## Installation

View File

@ -42,7 +42,7 @@ module Petstore
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} 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'] self.class_name = attributes[:'className']
end end

View File

@ -50,15 +50,15 @@ module Petstore
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} 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'] self.code = attributes[:'code']
end end
if attributes[:'type'] if attributes.has_key?(:'type')
self.type = attributes[:'type'] self.type = attributes[:'type']
end end
if attributes[:'message'] if attributes.has_key?(:'message')
self.message = attributes[:'message'] self.message = attributes[:'message']
end end

View File

@ -46,11 +46,11 @@ module Petstore
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} 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'] self.class_name = attributes[:'className']
end end
if attributes[:'declawed'] if attributes.has_key?(:'declawed')
self.declawed = attributes[:'declawed'] self.declawed = attributes[:'declawed']
end end

View File

@ -46,11 +46,11 @@ module Petstore
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} 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'] self.id = attributes[:'id']
end end
if attributes[:'name'] if attributes.has_key?(:'name')
self.name = attributes[:'name'] self.name = attributes[:'name']
end end

View File

@ -46,11 +46,11 @@ module Petstore
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} 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'] self.class_name = attributes[:'className']
end end
if attributes[:'breed'] if attributes.has_key?(:'breed')
self.breed = attributes[:'breed'] self.breed = attributes[:'breed']
end end

View File

@ -86,51 +86,51 @@ module Petstore
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} 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'] self.integer = attributes[:'integer']
end end
if attributes[:'int32'] if attributes.has_key?(:'int32')
self.int32 = attributes[:'int32'] self.int32 = attributes[:'int32']
end end
if attributes[:'int64'] if attributes.has_key?(:'int64')
self.int64 = attributes[:'int64'] self.int64 = attributes[:'int64']
end end
if attributes[:'number'] if attributes.has_key?(:'number')
self.number = attributes[:'number'] self.number = attributes[:'number']
end end
if attributes[:'float'] if attributes.has_key?(:'float')
self.float = attributes[:'float'] self.float = attributes[:'float']
end end
if attributes[:'double'] if attributes.has_key?(:'double')
self.double = attributes[:'double'] self.double = attributes[:'double']
end end
if attributes[:'string'] if attributes.has_key?(:'string')
self.string = attributes[:'string'] self.string = attributes[:'string']
end end
if attributes[:'byte'] if attributes.has_key?(:'byte')
self.byte = attributes[:'byte'] self.byte = attributes[:'byte']
end end
if attributes[:'binary'] if attributes.has_key?(:'binary')
self.binary = attributes[:'binary'] self.binary = attributes[:'binary']
end end
if attributes[:'date'] if attributes.has_key?(:'date')
self.date = attributes[:'date'] self.date = attributes[:'date']
end end
if attributes[:'dateTime'] if attributes.has_key?(:'dateTime')
self.date_time = attributes[:'dateTime'] self.date_time = attributes[:'dateTime']
end end
if attributes[:'password'] if attributes.has_key?(:'password')
self.password = attributes[:'password'] self.password = attributes[:'password']
end end

View File

@ -43,7 +43,7 @@ module Petstore
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} 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'] self.name = attributes[:'name']
end end

View File

@ -43,7 +43,7 @@ module Petstore
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} 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'] self._return = attributes[:'return']
end end

View File

@ -51,15 +51,15 @@ module Petstore
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} 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'] self.name = attributes[:'name']
end end
if attributes[:'snake_case'] if attributes.has_key?(:'snake_case')
self.snake_case = attributes[:'snake_case'] self.snake_case = attributes[:'snake_case']
end end
if attributes[:'property'] if attributes.has_key?(:'property')
self.property = attributes[:'property'] self.property = attributes[:'property']
end end

View File

@ -63,27 +63,27 @@ module Petstore
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} 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'] self.id = attributes[:'id']
end end
if attributes[:'petId'] if attributes.has_key?(:'petId')
self.pet_id = attributes[:'petId'] self.pet_id = attributes[:'petId']
end end
if attributes[:'quantity'] if attributes.has_key?(:'quantity')
self.quantity = attributes[:'quantity'] self.quantity = attributes[:'quantity']
end end
if attributes[:'shipDate'] if attributes.has_key?(:'shipDate')
self.ship_date = attributes[:'shipDate'] self.ship_date = attributes[:'shipDate']
end end
if attributes[:'status'] if attributes.has_key?(:'status')
self.status = attributes[:'status'] self.status = attributes[:'status']
end end
if attributes[:'complete'] if attributes.has_key?(:'complete')
self.complete = attributes[:'complete'] self.complete = attributes[:'complete']
else else
self.complete = false self.complete = false

View File

@ -63,31 +63,31 @@ module Petstore
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} 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'] self.id = attributes[:'id']
end end
if attributes[:'category'] if attributes.has_key?(:'category')
self.category = attributes[:'category'] self.category = attributes[:'category']
end end
if attributes[:'name'] if attributes.has_key?(:'name')
self.name = attributes[:'name'] self.name = attributes[:'name']
end end
if attributes[:'photoUrls'] if attributes.has_key?(:'photoUrls')
if (value = attributes[:'photoUrls']).is_a?(Array) if (value = attributes[:'photoUrls']).is_a?(Array)
self.photo_urls = value self.photo_urls = value
end end
end end
if attributes[:'tags'] if attributes.has_key?(:'tags')
if (value = attributes[:'tags']).is_a?(Array) if (value = attributes[:'tags']).is_a?(Array)
self.tags = value self.tags = value
end end
end end
if attributes[:'status'] if attributes.has_key?(:'status')
self.status = attributes[:'status'] self.status = attributes[:'status']
end end

View File

@ -42,7 +42,7 @@ module Petstore
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} 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]'] self.special_property_name = attributes[:'$special[property.name]']
end end

View File

@ -46,11 +46,11 @@ module Petstore
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} 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'] self.id = attributes[:'id']
end end
if attributes[:'name'] if attributes.has_key?(:'name')
self.name = attributes[:'name'] self.name = attributes[:'name']
end end

View File

@ -71,35 +71,35 @@ module Petstore
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} 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'] self.id = attributes[:'id']
end end
if attributes[:'username'] if attributes.has_key?(:'username')
self.username = attributes[:'username'] self.username = attributes[:'username']
end end
if attributes[:'firstName'] if attributes.has_key?(:'firstName')
self.first_name = attributes[:'firstName'] self.first_name = attributes[:'firstName']
end end
if attributes[:'lastName'] if attributes.has_key?(:'lastName')
self.last_name = attributes[:'lastName'] self.last_name = attributes[:'lastName']
end end
if attributes[:'email'] if attributes.has_key?(:'email')
self.email = attributes[:'email'] self.email = attributes[:'email']
end end
if attributes[:'password'] if attributes.has_key?(:'password')
self.password = attributes[:'password'] self.password = attributes[:'password']
end end
if attributes[:'phone'] if attributes.has_key?(:'phone')
self.phone = attributes[:'phone'] self.phone = attributes[:'phone']
end end
if attributes[:'userStatus'] if attributes.has_key?(:'userStatus')
self.user_status = attributes[:'userStatus'] self.user_status = attributes[:'userStatus']
end end

View File

@ -30,8 +30,16 @@ class ArrayMapObject < Petstore::Category
end end
end end
describe 'BaseObject' do 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 describe 'array and map properties' do
let(:obj) { ArrayMapObject.new } let(:obj) { ArrayMapObject.new }