I have the following in my Protobuf message:
enum SegmentType {
UNKNOWN = 0;
TYPE_1 = 1;
TYPE_2 = 2;
TYPE_3 = 3;
}
optional SegmentType segment_type = 1 [default = UNKNOWN]
Instead of GeneratedEnum
type, I would like to generate a string, with value as the particular type. For example
SegmentType: String = "TYPE_1"
This link explains how to map as a custom type, but it's not clear to me how to map as a value type. When I try the following, ScalaPB is showing error that it should be implemented in String companion class.
implicit val segmentType = TypeMapper[SegmentType, String](_.name)(SegmentType.fromName(_).get)
How can I achieve it? Also is there a way to transform all Enum
types in a message as String
?