twirp-ruby icon indicating copy to clipboard operation
twirp-ruby copied to clipboard

Namespace not retained when generating rpc calls

Open bk-one opened this issue 3 years ago • 2 comments

Please consider the following .proto file:

package package.rpc.asks;
import "package/actions/asks.proto";
service Ask {
  rpc GetAskSnapshot(package.actions.asks.RequestAskSnapshot) returns (package.actions.asks.AskSnapshot) { }
}

I would expect this to generate a Ruby file

module Package
  module Rpc
    module Asks
      class AskService < Twirp::Service
        package 'superlist.rpc.asks'
        service 'Ask'
        rpc :GetAskSnapshot, Package::Actions::Asks::RequestAskSnapshot, Package::Actions::Asks::AskSnapshot, :ruby_method => :get_ask_snapshot
      end

however, it drops the package name for the parameter and generates

module Package
  module Rpc
    module Asks
      class AskService < Twirp::Service
        package 'superlist.rpc.asks'
        service 'Ask'
        rpc :GetAskSnapshot, RequestAskSnapshot, AskSnapshot, :ruby_method => :get_ask_snapshot
      end

which results in an error when trying to import the service file. The RequestAskSnapshot is expected as Package::Rpc::Asks::AskService::RequestAskSnapshot which doesn't exists (as it's supposed to be Package::Actions::Asks::RequestAskSnapshot).

Am I missing something?

bk-one avatar Apr 09 '22 14:04 bk-one

Hi, yes this appears to be a bug. Right now the only workaround for this is to manually edit the generated file.

wmatveyenko avatar May 16 '22 20:05 wmatveyenko