diff --git a/modules/swagger-codegen/src/main/resources/ruby/api.mustache b/modules/swagger-codegen/src/main/resources/ruby/api.mustache index b7821131e6..f2564a7889 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api.mustache @@ -44,13 +44,12 @@ class {{classname}} # header parameters headers = {} - _header_accept = '{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [{{#consumes}}'{{mediaType}}'{{#hasMore}},{{/hasMore}}{{/consumes}}]; - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = '{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' {{#headerParams}}{{#optional}}headers[:'{{{baseName}}}'] = options[:'{{{paramName}}}'] if options[:'{{{paramName}}}']{{/optional}}{{/headerParams}} {{#headerParams}}{{^optional}}headers[:'{{{baseName}}}'] = {{{paramName}}}{{/optional}}{{/headerParams}} diff --git a/samples/client/petstore/ruby/lib/pet_api.rb b/samples/client/petstore/ruby/lib/pet_api.rb index 8df1315311..28e65cddaf 100644 --- a/samples/client/petstore/ruby/lib/pet_api.rb +++ b/samples/client/petstore/ruby/lib/pet_api.rb @@ -35,13 +35,12 @@ class PetApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [('application/json','application/xml',); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = ['application/json', 'application/xml', ] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -104,13 +103,12 @@ class PetApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [('application/json','application/xml',); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = ['application/json', 'application/xml', ] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -173,13 +171,12 @@ class PetApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -224,13 +221,12 @@ class PetApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -276,13 +272,12 @@ class PetApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -331,13 +326,12 @@ class PetApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [('application/x-www-form-urlencoded',); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = ['application/x-www-form-urlencoded', ] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -385,13 +379,12 @@ class PetApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' headers[:'api_key'] = api_key @@ -439,13 +432,12 @@ class PetApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [('multipart/form-data',); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = ['multipart/form-data', ] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' diff --git a/samples/client/petstore/ruby/lib/store_api.rb b/samples/client/petstore/ruby/lib/store_api.rb index f33ff754a8..5e66e64f4c 100644 --- a/samples/client/petstore/ruby/lib/store_api.rb +++ b/samples/client/petstore/ruby/lib/store_api.rb @@ -33,13 +33,12 @@ class StoreApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -84,13 +83,12 @@ class StoreApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -155,13 +153,12 @@ class StoreApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -206,13 +203,12 @@ class StoreApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' diff --git a/samples/client/petstore/ruby/lib/user_api.rb b/samples/client/petstore/ruby/lib/user_api.rb index f882f94bd9..d7b6604910 100644 --- a/samples/client/petstore/ruby/lib/user_api.rb +++ b/samples/client/petstore/ruby/lib/user_api.rb @@ -35,13 +35,12 @@ class UserApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -104,13 +103,12 @@ class UserApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -173,13 +171,12 @@ class UserApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -244,13 +241,12 @@ class UserApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -292,13 +288,12 @@ class UserApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -342,13 +337,12 @@ class UserApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -395,13 +389,12 @@ class UserApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json' @@ -465,13 +458,12 @@ class UserApi # header parameters headers = {} - _header_accept = 'application/json, application/xml'; - if (_header_accept != '') { - headerParams['Accept'] = _header_accept; - } - _header_content_type = [(); - headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'; - + _header_accept = 'application/json, application/xml' + if _header_accept != '' + headerParams['Accept'] = _header_accept + end + _header_content_type = [] + headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'