Respect discovered methods with colons in path
authorremi Taylor <remily@google.com>
Tue, 14 Apr 2015 04:38:47 +0000 (21:38 -0700)
committerremi Taylor <remily@google.com>
Tue, 14 Apr 2015 04:38:47 +0000 (21:38 -0700)
lib/google/api_client/discovery/method.rb
spec/google/api_client/discovery_spec.rb

index 79d1468ff0bb9c3128fce02d72d69eac06a24c52..3a06857c0e3d559f0e4e20813767d0c3dee639a8 100644 (file)
@@ -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
 
index d9acf3374eab2ee28f9b45eada0d4f7de5a80ed6..637d25e9f1ba6903c52c26e1ad9a9c2fc524faf0 100644 (file)
@@ -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