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

View File

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

View File

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