From 94a979b5126e6bb4e4a1779e512131ffe32525c1 Mon Sep 17 00:00:00 2001 From: remi Taylor Date: Mon, 13 Apr 2015 21:38:47 -0700 Subject: [PATCH] Respect discovered methods with colons in path --- lib/google/api_client/discovery/method.rb | 2 +- spec/google/api_client/discovery_spec.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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