From 0ac1ef266f56fab222eb5868d4f5a569f41a36ba Mon Sep 17 00:00:00 2001 From: xhh Date: Fri, 26 Jun 2015 16:04:18 +0800 Subject: [PATCH] Avoid more monkey-patching --- .../codegen/languages/RubyClientCodegen.java | 1 - .../src/main/resources/ruby/monkey.mustache | 31 ------------------- .../resources/ruby/swagger/request.mustache | 2 +- .../resources/ruby/swagger_client.mustache | 1 - 4 files changed, 1 insertion(+), 34 deletions(-) delete mode 100644 modules/swagger-codegen/src/main/resources/ruby/monkey.mustache diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java index e7260d525d..0ea0be21a7 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java @@ -107,7 +107,6 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("swagger_client.gemspec.mustache", "", gemName + ".gemspec")); supportingFiles.add(new SupportingFile("swagger_client.mustache", libFolder, gemName + ".rb")); String baseFolder = libFolder + File.separator + gemName; - supportingFiles.add(new SupportingFile("monkey.mustache", baseFolder, "monkey.rb")); supportingFiles.add(new SupportingFile("swagger.mustache", baseFolder, "swagger.rb")); String swaggerFolder = baseFolder + File.separator + "swagger"; supportingFiles.add(new SupportingFile("swagger" + File.separator + "request.mustache", swaggerFolder, "request.rb")); diff --git a/modules/swagger-codegen/src/main/resources/ruby/monkey.mustache b/modules/swagger-codegen/src/main/resources/ruby/monkey.mustache deleted file mode 100644 index 2f5b96f884..0000000000 --- a/modules/swagger-codegen/src/main/resources/ruby/monkey.mustache +++ /dev/null @@ -1,31 +0,0 @@ -class Hash - unless Hash.method_defined? :stringify_keys - def stringify_keys - inject({}) do |options, (key, value)| - options[key.to_s] = value - options - end - end - end - - unless Hash.method_defined? :stringify_keys! - def stringify_keys! - self.replace(self.stringify_keys) - end - end - - unless Hash.method_defined? :symbolize_keys - def symbolize_keys - inject({}) do |options, (key, value)| - options[(key.to_sym rescue key) || key] = value - options - end - end - end - - unless Hash.method_defined? :symbolize_keys! - def symbolize_keys! - self.replace(self.symbolize_keys) - end - end -end diff --git a/modules/swagger-codegen/src/main/resources/ruby/swagger/request.mustache b/modules/swagger-codegen/src/main/resources/ruby/swagger/request.mustache index bd5b2991ca..decf7aa770 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/swagger/request.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/swagger/request.mustache @@ -119,7 +119,7 @@ module {{moduleName}} def make request_options = { :method => self.http_method, - :headers => self.headers.stringify_keys, + :headers => self.headers, :ssl_verifypeer => Swagger.configuration.verify_ssl, :cainfo => Swagger.configuration.ssl_ca_cert, :verbose => Swagger.configuration.debug diff --git a/modules/swagger-codegen/src/main/resources/ruby/swagger_client.mustache b/modules/swagger-codegen/src/main/resources/ruby/swagger_client.mustache index 0be00aaec9..4ed0839f6e 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/swagger_client.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/swagger_client.mustache @@ -1,5 +1,4 @@ # Swagger common files -require '{{gemName}}/monkey' require '{{gemName}}/swagger' require '{{gemName}}/swagger/configuration' require '{{gemName}}/swagger/api_error'