Update generator to use batchPath instead of hardcoded path

This commit is contained in:
Steven Bazyl 2017-03-06 12:24:30 -08:00
parent cf38f15a08
commit 687223feb4
3 changed files with 7 additions and 0 deletions

View File

@ -42,6 +42,7 @@ module Google
<% end -%> <% end -%>
def initialize def initialize
super('<%= api.root_url %>', '<%= api.service_path %>') super('<%= api.root_url %>', '<%= api.service_path %>')
@batch_path = '<%= api.batch_path %>'
end end
<% for api_method in api.all_methods -%> <% for api_method in api.all_methods -%>
<%= indent(include('method', :api_method => api_method, :api => api), 8) -%> <%= indent(include('method', :api_method => api_method, :api => api), 8) -%>

View File

@ -7,6 +7,7 @@
"basePath": "/test/", "basePath": "/test/",
"rootUrl": "https://www.googleapis.com/", "rootUrl": "https://www.googleapis.com/",
"servicePath": "test/v1/", "servicePath": "test/v1/",
"batchPath": "batch/test/v1",
"rpcPath": "/rpc", "rpcPath": "/rpc",
"auth": { "auth": {
"oauth2": { "oauth2": {

View File

@ -30,6 +30,7 @@ RSpec.describe Google::Apis::Generator do
puts generator.dump_api_names puts generator.dump_api_names
tempdir = Dir.mktmpdir tempdir = Dir.mktmpdir
generated_files.each do |key, content| generated_files.each do |key, content|
puts content
path = File.join(tempdir, key) path = File.join(tempdir, key)
FileUtils.mkdir_p(File.dirname(path)) FileUtils.mkdir_p(File.dirname(path))
File.open(path, 'w') do |f| File.open(path, 'w') do |f|
@ -47,6 +48,10 @@ RSpec.describe Google::Apis::Generator do
expect(service.root_url.to_s).to eql('https://www.googleapis.com/') expect(service.root_url.to_s).to eql('https://www.googleapis.com/')
end end
it 'should set the batch path' do
expect(service.batch_path).to eql('batch/test/v1')
end
it 'should define global methods from discovery' do it 'should define global methods from discovery' do
expect(service.method(:query)).to_not be_nil expect(service.method(:query)).to_not be_nil
end end