diff --git a/lib/google/api_client/discovery/method.rb b/lib/google/api_client/discovery/method.rb index 79d1468ff..3a06857c0 100644 --- a/lib/google/api_client/discovery/method.rb +++ b/lib/google/api_client/discovery/method.rb @@ -108,7 +108,7 @@ module Google # @return [Addressable::Template] The URI template. def uri_template return @uri_template ||= Addressable::Template.new( - self.method_base.join(Addressable::URI.parse(@discovery_document['path'])) + self.method_base.join(Addressable::URI.parse("./" + @discovery_document['path'])) ) end diff --git a/spec/google/api_client/discovery_spec.rb b/spec/google/api_client/discovery_spec.rb index d9acf3374..637d25e9f 100644 --- a/spec/google/api_client/discovery_spec.rb +++ b/spec/google/api_client/discovery_spec.rb @@ -688,5 +688,21 @@ RSpec.describe Google::APIClient do it 'should correctly determine the service root_uri' do expect(@pubsub.root_uri.to_s).to eq('https://pubsub.googleapis.com/') end + + it 'should discover correct method URIs' do + list = CLIENT.discovered_method( + "pubsub.projects.topics.list", "pubsub", "v1beta2" + ) + expect(list.uri_template.pattern).to eq( + "https://pubsub.googleapis.com/v1beta2/{+project}/topics" + ) + + publish = CLIENT.discovered_method( + "pubsub.projects.topics.publish", "pubsub", "v1beta2" + ) + expect(publish.uri_template.pattern).to eq( + "https://pubsub.googleapis.com/v1beta2/{+topic}:publish" + ) + end end end