forked from loafle/openapi-generator-original
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:
commit
a03574e119
@ -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);
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user