mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 22:50:53 +00:00
parent
860b551e9b
commit
e0dfc1b43d
@ -138,7 +138,7 @@ module {{moduleName}}
|
|||||||
end
|
end
|
||||||
|
|
||||||
def base_url
|
def base_url
|
||||||
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}"
|
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
||||||
URI.encode(url)
|
URI.encode(url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ module Petstore
|
|||||||
end
|
end
|
||||||
|
|
||||||
def base_url
|
def base_url
|
||||||
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}"
|
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
||||||
URI.encode(url)
|
URI.encode(url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
25
samples/client/petstore/ruby/spec/configuration_spec.rb
Normal file
25
samples/client/petstore/ruby/spec/configuration_spec.rb
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Petstore::Configuration do
|
||||||
|
let(:config) { Petstore::Configuration.instance }
|
||||||
|
|
||||||
|
before(:each) do
|
||||||
|
Petstore.configure do |c|
|
||||||
|
c.host = 'petstore.swagger.io'
|
||||||
|
c.base_path = 'v2'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#base_url' do
|
||||||
|
it 'should have the default value' do
|
||||||
|
config.base_url.should == 'http://petstore.swagger.io/v2'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should remove trailing slashes' do
|
||||||
|
[nil, '', '/', '//'].each do |base_path|
|
||||||
|
config.base_path = base_path
|
||||||
|
config.base_url.should == 'http://petstore.swagger.io'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user