fix bug with ruby header parameter, remove extra linebreak in generated

code
This commit is contained in:
William Cheng 2015-03-18 16:33:00 +08:00
parent bb45790375
commit d0dcb2fb43
10 changed files with 95 additions and 190 deletions

View File

@ -23,10 +23,8 @@ class {{classname}}
# set default values and merge with input # set default values and merge with input
options = { options = {
{{#allParams}} {{#allParams}}:'{{paramName}}' => {{paramName}}{{#hasMore}},{{/hasMore}}
:{{paramName}} => {{paramName}}{{#hasMore}}, {{/allParams}}
{{/hasMore}}
{{/allParams}}
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -38,12 +36,10 @@ class {{classname}}
query_param_keys.include? key query_param_keys.include? key
end end
{{#headerParams}}headers = { # header parameters, if any
{{{paramName}}}: {{{paramName}}}, headers = {}
} {{#headerParams}}{{#optional}}headers[:'{{{baseName}}}'] = options[:'{{{paramName}}}'] if options[:'{{{paramName}}}']{{/optional}}{{/headerParams}}
{{/headerParams}} {{#headerParams}}{{^optional}}headers[:'{{{baseName}}}'] = {{{paramName}}}{{/optional}}{{/headerParams}}
{{^headerParams}}headers = nil
{{/headerParams}}
# http body (model) # http body (model)
post_body = nil post_body = nil

View File

@ -6,8 +6,7 @@ class {{classname}}
# :internal => :external # :internal => :external
def self.attribute_map def self.attribute_map
{ {
{{#vars}} {{#vars}}:{{{name}}} => :'{{{baseName}}}'{{#hasMore}},{{/hasMore}}
:{{{name}}} => :{{{baseName}}}{{#hasMore}},{{/hasMore}}
{{/vars}} {{/vars}}
} }
end end
@ -17,13 +16,9 @@ class {{classname}}
# Morph attribute keys into undescored rubyish style # Morph attribute keys into undescored rubyish style
{{#vars}} {{#vars}}
if self.class.attribute_map[:"{{{name}}}"] if self.class.attribute_map[:"{{{name}}}"]
{{#isContainer}} {{#isContainer}}if (value = attributes["{{{baseName}}}"]).is_a?(Array)
if (value = attributes["{{{baseName}}}"]).is_a?(Array) @{{{name}}} = value{{#complexType}}.map{ |v| {{complexType}}.new(v) }{{/complexType}}
@{{{name}}} = value{{#complexType}}.map{ |v| {{complexType}}.new(v) }{{/complexType}}{{newline}} end{{/isContainer}}{{^isContainer}}@{{{name}}} = attributes["{{{baseName}}}"]{{/isContainer}}
end
{{/isContainer}}{{^isContainer}}
@{{{name}}} = attributes["{{{baseName}}}"]
{{/isContainer}}
end end
{{/vars}} {{/vars}}
end end

View File

@ -16,9 +16,8 @@ class PetApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:body => body :body => body
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -29,8 +28,9 @@ class PetApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -77,9 +77,8 @@ class PetApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:body => body :body => body
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -90,8 +89,9 @@ class PetApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -138,9 +138,8 @@ class PetApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:status => status :status => status
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -151,8 +150,9 @@ class PetApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -180,9 +180,8 @@ class PetApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:tags => tags :tags => tags
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -193,8 +192,9 @@ class PetApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -222,9 +222,8 @@ class PetApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:petId => petId :petId => petId
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -236,8 +235,9 @@ class PetApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -264,15 +264,10 @@ class PetApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:petId => petId, :petId => petId,
:name => name, :name => name,
:status => status :status => status
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -284,8 +279,9 @@ class PetApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -313,12 +309,9 @@ class PetApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:api_key => api_key, :api_key => api_key,
:petId => petId :petId => petId
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -330,11 +323,10 @@ class PetApi
query_param_keys.include? key query_param_keys.include? key
end end
headers = { # header parameters, if any
api_key: api_key, headers = {}
}
headers[:'api_key'] = api_key
# http body (model) # http body (model)
post_body = nil post_body = nil
@ -359,15 +351,10 @@ class PetApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:petId => petId, :petId => petId,
:additionalMetadata => additionalMetadata, :additionalMetadata => additionalMetadata,
:file => file :file => file
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -379,8 +366,9 @@ class PetApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)

View File

@ -16,7 +16,7 @@ class StoreApi
# set default values and merge with input # set default values and merge with input
options = { options = {
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -27,8 +27,9 @@ class StoreApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -56,9 +57,8 @@ class StoreApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:body => body :body => body
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -69,8 +69,9 @@ class StoreApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -118,9 +119,8 @@ class StoreApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:orderId => orderId :orderId => orderId
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -132,8 +132,9 @@ class StoreApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -160,9 +161,8 @@ class StoreApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:orderId => orderId :orderId => orderId
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -174,8 +174,9 @@ class StoreApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)

View File

@ -16,9 +16,8 @@ class UserApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:body => body :body => body
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -29,8 +28,9 @@ class UserApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -77,9 +77,8 @@ class UserApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:body => body :body => body
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -90,8 +89,9 @@ class UserApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -138,9 +138,8 @@ class UserApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:body => body :body => body
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -151,8 +150,9 @@ class UserApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -199,12 +199,9 @@ class UserApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:username => username, :username => username,
:password => password :password => password
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -215,8 +212,9 @@ class UserApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -243,7 +241,7 @@ class UserApi
# set default values and merge with input # set default values and merge with input
options = { options = {
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -254,8 +252,9 @@ class UserApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -281,9 +280,8 @@ class UserApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:username => username :username => username
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -295,8 +293,9 @@ class UserApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -323,12 +322,9 @@ class UserApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:username => username, :username => username,
:body => body :body => body
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -340,8 +336,9 @@ class UserApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)
@ -388,9 +385,8 @@ class UserApi
# set default values and merge with input # set default values and merge with input
options = { options = {
:username => username :username => username
}.merge(opts) }.merge(opts)
#resource path #resource path
@ -402,8 +398,9 @@ class UserApi
query_param_keys.include? key query_param_keys.include? key
end end
# header parameters, if any
headers = {}
headers = nil
# http body (model) # http body (model)

View File

@ -4,10 +4,8 @@ class Category
# :internal => :external # :internal => :external
def self.attribute_map def self.attribute_map
{ {
:id => :'id',
:id => :id, :name => :'name'
:name => :name
} }
end end
@ -17,15 +15,11 @@ class Category
# Morph attribute keys into undescored rubyish style # Morph attribute keys into undescored rubyish style
if self.class.attribute_map[:"id"] if self.class.attribute_map[:"id"]
@id = attributes["id"] @id = attributes["id"]
end end
if self.class.attribute_map[:"name"] if self.class.attribute_map[:"name"]
@name = attributes["name"] @name = attributes["name"]
end end
end end

View File

@ -4,18 +4,12 @@ class Order
# :internal => :external # :internal => :external
def self.attribute_map def self.attribute_map
{ {
:id => :'id',
:id => :id, :petId => :'petId',
:quantity => :'quantity',
:petId => :petId, :shipDate => :'shipDate',
:status => :'status',
:quantity => :quantity, :complete => :'complete'
:shipDate => :shipDate,
:status => :status,
:complete => :complete
} }
end end
@ -25,39 +19,27 @@ class Order
# Morph attribute keys into undescored rubyish style # Morph attribute keys into undescored rubyish style
if self.class.attribute_map[:"id"] if self.class.attribute_map[:"id"]
@id = attributes["id"] @id = attributes["id"]
end end
if self.class.attribute_map[:"petId"] if self.class.attribute_map[:"petId"]
@petId = attributes["petId"] @petId = attributes["petId"]
end end
if self.class.attribute_map[:"quantity"] if self.class.attribute_map[:"quantity"]
@quantity = attributes["quantity"] @quantity = attributes["quantity"]
end end
if self.class.attribute_map[:"shipDate"] if self.class.attribute_map[:"shipDate"]
@shipDate = attributes["shipDate"] @shipDate = attributes["shipDate"]
end end
if self.class.attribute_map[:"status"] if self.class.attribute_map[:"status"]
@status = attributes["status"] @status = attributes["status"]
end end
if self.class.attribute_map[:"complete"] if self.class.attribute_map[:"complete"]
@complete = attributes["complete"] @complete = attributes["complete"]
end end
end end

View File

@ -4,18 +4,12 @@ class Pet
# :internal => :external # :internal => :external
def self.attribute_map def self.attribute_map
{ {
:id => :'id',
:id => :id, :category => :'category',
:name => :'name',
:category => :category, :photoUrls => :'photoUrls',
:tags => :'tags',
:name => :name, :status => :'status'
:photoUrls => :photoUrls,
:tags => :tags,
:status => :status
} }
end end
@ -25,43 +19,31 @@ class Pet
# Morph attribute keys into undescored rubyish style # Morph attribute keys into undescored rubyish style
if self.class.attribute_map[:"id"] if self.class.attribute_map[:"id"]
@id = attributes["id"] @id = attributes["id"]
end end
if self.class.attribute_map[:"category"] if self.class.attribute_map[:"category"]
@category = attributes["category"] @category = attributes["category"]
end end
if self.class.attribute_map[:"name"] if self.class.attribute_map[:"name"]
@name = attributes["name"] @name = attributes["name"]
end end
if self.class.attribute_map[:"photoUrls"] if self.class.attribute_map[:"photoUrls"]
if (value = attributes["photoUrls"]).is_a?(Array) if (value = attributes["photoUrls"]).is_a?(Array)
@photoUrls = value @photoUrls = value
end end
end end
if self.class.attribute_map[:"tags"] if self.class.attribute_map[:"tags"]
if (value = attributes["tags"]).is_a?(Array) if (value = attributes["tags"]).is_a?(Array)
@tags = value.map{ |v| Tag.new(v) } @tags = value.map{ |v| Tag.new(v) }
end end
end end
if self.class.attribute_map[:"status"] if self.class.attribute_map[:"status"]
@status = attributes["status"] @status = attributes["status"]
end end
end end

View File

@ -4,10 +4,8 @@ class Tag
# :internal => :external # :internal => :external
def self.attribute_map def self.attribute_map
{ {
:id => :'id',
:id => :id, :name => :'name'
:name => :name
} }
end end
@ -17,15 +15,11 @@ class Tag
# Morph attribute keys into undescored rubyish style # Morph attribute keys into undescored rubyish style
if self.class.attribute_map[:"id"] if self.class.attribute_map[:"id"]
@id = attributes["id"] @id = attributes["id"]
end end
if self.class.attribute_map[:"name"] if self.class.attribute_map[:"name"]
@name = attributes["name"] @name = attributes["name"]
end end
end end

View File

@ -4,22 +4,14 @@ class User
# :internal => :external # :internal => :external
def self.attribute_map def self.attribute_map
{ {
:id => :'id',
:id => :id, :username => :'username',
:firstName => :'firstName',
:username => :username, :lastName => :'lastName',
:email => :'email',
:firstName => :firstName, :password => :'password',
:phone => :'phone',
:lastName => :lastName, :userStatus => :'userStatus'
:email => :email,
:password => :password,
:phone => :phone,
:userStatus => :userStatus
} }
end end
@ -29,51 +21,35 @@ class User
# Morph attribute keys into undescored rubyish style # Morph attribute keys into undescored rubyish style
if self.class.attribute_map[:"id"] if self.class.attribute_map[:"id"]
@id = attributes["id"] @id = attributes["id"]
end end
if self.class.attribute_map[:"username"] if self.class.attribute_map[:"username"]
@username = attributes["username"] @username = attributes["username"]
end end
if self.class.attribute_map[:"firstName"] if self.class.attribute_map[:"firstName"]
@firstName = attributes["firstName"] @firstName = attributes["firstName"]
end end
if self.class.attribute_map[:"lastName"] if self.class.attribute_map[:"lastName"]
@lastName = attributes["lastName"] @lastName = attributes["lastName"]
end end
if self.class.attribute_map[:"email"] if self.class.attribute_map[:"email"]
@email = attributes["email"] @email = attributes["email"]
end end
if self.class.attribute_map[:"password"] if self.class.attribute_map[:"password"]
@password = attributes["password"] @password = attributes["password"]
end end
if self.class.attribute_map[:"phone"] if self.class.attribute_map[:"phone"]
@phone = attributes["phone"] @phone = attributes["phone"]
end end
if self.class.attribute_map[:"userStatus"] if self.class.attribute_map[:"userStatus"]
@userStatus = attributes["userStatus"] @userStatus = attributes["userStatus"]
end end
end end