Merge pull request #631 from xhh/ruby-config

Fix hard-coded values in Ruby client: scheme, host and base_path
This commit is contained in:
Tony Tam 2015-04-15 22:54:46 -07:00
commit a03574e119
3 changed files with 11 additions and 7 deletions

View File

@ -93,12 +93,14 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
} }
StringBuilder hostBuilder = new StringBuilder(); StringBuilder hostBuilder = new StringBuilder();
String scheme;
if (swagger.getSchemes() != null && swagger.getSchemes().size() > 0) { if (swagger.getSchemes() != null && swagger.getSchemes().size() > 0) {
hostBuilder.append(swagger.getSchemes().get(0).toValue()); scheme = swagger.getSchemes().get(0).toValue();
hostBuilder.append("://");
} else { } else {
hostBuilder.append("https://"); scheme = "https";
} }
hostBuilder.append(scheme);
hostBuilder.append("://");
if (swagger.getHost() != null) { if (swagger.getHost() != null) {
hostBuilder.append(swagger.getHost()); hostBuilder.append(swagger.getHost());
} else { } else {
@ -209,6 +211,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
bundle.put("host", swagger.getHost()); bundle.put("host", swagger.getHost());
} }
bundle.put("basePath", basePath); bundle.put("basePath", basePath);
bundle.put("scheme", scheme);
bundle.put("contextPath", contextPath); bundle.put("contextPath", contextPath);
bundle.put("apiInfo", apis); bundle.put("apiInfo", apis);
bundle.put("models", allModels); bundle.put("models", allModels);

View File

@ -7,6 +7,8 @@ require 'logger'
module Swagger module Swagger
@configuration = Configuration.new
class << self class << self
attr_accessor :logger attr_accessor :logger
@ -27,7 +29,6 @@ module Swagger
# end # end
# #
def configure def configure
self.configuration ||= Configuration.new
yield(configuration) if block_given? yield(configuration) if block_given?
# Configure logger. Default to use Rails # Configure logger. Default to use Rails

View File

@ -8,9 +8,9 @@ module Swagger
# Defaults go in here.. # Defaults go in here..
def initialize def initialize
@format = 'json' @format = 'json'
@scheme = 'http' @scheme = '{{scheme}}'
@host = 'petstore.swagger.io' @host = '{{host}}'
@base_path = '/v2' @base_path = '{{contextPath}}'
@user_agent = "ruby-swagger-#{Swagger::VERSION}" @user_agent = "ruby-swagger-#{Swagger::VERSION}"
@inject_format = false @inject_format = false
@force_ending_format = false @force_ending_format = false