googleapis/gapic-generator-ruby

Conversion functions for google.type.*?

shouichi opened this issue · 5 comments

Hello, I'm not really sure where to report but here I go.

There are helper functions that convert ruby objects and proto messages e.g., Gapic::Protobuf.timestamp_to_time. Are there equivalent functions for google.type.*. For example, I need a conversion function that convers Google::Type::Date to Date and vice versa.

Thank you.

Hi, sorry we haven't gotten to this.

For general conversion utility methods, I wonder if it makes more sense for them to go into the google-protobuf gem itself. Perhaps here: https://github.com/protocolbuffers/protobuf/blob/main/ruby/lib/google/protobuf/well_known_types.rb. That way it would be available to any user of protobuf.

The gapic-common gem in this repository is kind of specific to Google API client libraries, and generally has utility methods that are used internally by the code generator or the generated clients, or that are present for backward compatibility with earlier clients. Adding things here might not reach a wide audience, as the gem isn't meant to be used directly by end users.

@dazuma I realized that I personally need utility functions for google.type.Date which is not part of the standard protobuf messages. Thus it is strange to add them to https://github.com/protocolbuffers/protobuf. What do you think?

Oh, I see. Timestamp is under google.protobuf which is built-in, but Date is under google.type which is a standard type but not built-in. So you're right, it probably doesn't make sense to add those to the protobuf gem itself. However, as mentioned earlier, gapic-common is not really the right location either since it's not intended to be used directly other than by generated google-specific clients. I think we might consider adding utility methods like that to this gem which provides definitions for those protos. Right now it's generated, but we could add a simple mechanism to append handwritten code to it.