mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
Merge pull request #1401 from xhh/ruby-base-url-slashes
Ruby client: remove trailing slashes from base_url
This commit is contained in:
commit
90eab19305
@ -138,7 +138,7 @@ module {{moduleName}}
|
||||
end
|
||||
|
||||
def base_url
|
||||
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}"
|
||||
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
||||
URI.encode(url)
|
||||
end
|
||||
|
||||
|
@ -138,7 +138,7 @@ module Petstore
|
||||
end
|
||||
|
||||
def base_url
|
||||
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}"
|
||||
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
||||
URI.encode(url)
|
||||
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…
Reference in New Issue
Block a user