@@ -315,11 +315,11 @@ func (g *protoGenerator) handleEnum(e *thrifter.Enum) {
315315 // proto 3 enum first element must be zero, add a default element to it
316316 if ele .ID > 0 && g .conf .syntax == 3 {
317317 g .writeIndent ()
318- name := utils .CaseConvert (g .conf .nameCase , fmt .Sprintf ("%s_Unknown" , e .Ident ))
318+ name := utils .CaseConvert (g .conf .fieldCase , fmt .Sprintf ("%s_Unknown" , e .Ident ))
319319 g .protoContent .WriteString (fmt .Sprintf ("%s = 0;\n " , name ))
320320 }
321321 }
322- name := utils .CaseConvert (g .conf .nameCase , ele .Ident )
322+ name := utils .CaseConvert (g .conf .fieldCase , ele .Ident )
323323 g .writeIndent ()
324324 g .protoContent .WriteString (fmt .Sprintf ("%s = %d;" , name , ele .ID ))
325325
@@ -360,7 +360,7 @@ func (g *protoGenerator) handleStruct(s *thrifter.Struct) {
360360 continue
361361 }
362362
363- name := utils .CaseConvert (g .conf .nameCase , ele .Ident )
363+ name := utils .CaseConvert (g .conf .fieldCase , ele .Ident )
364364
365365 switch ele .FieldType .Type {
366366 // set would be list
@@ -378,6 +378,7 @@ func (g *protoGenerator) handleStruct(s *thrifter.Struct) {
378378 g .protoContent .WriteString (fmt .Sprintf ("repeated %s %s = %d;" , fieldType , name , ele .ID ))
379379
380380 case thrifter .FIELD_TYPE_MAP :
381+ optional := g .conf .syntax == 2 && ele .Requiredness == "optional"
381382 fieldType , keyType := "" , ""
382383 // TODO: support nested types for map value
383384 if ele .FieldType .Map .Value .Type == thrifter .FIELD_TYPE_BASE {
@@ -391,6 +392,9 @@ func (g *protoGenerator) handleStruct(s *thrifter.Struct) {
391392 keyType , _ = g .typeConverter (ele .FieldType .Map .Key .Ident )
392393 }
393394 g .writeIndent ()
395+ if optional {
396+ g .protoContent .WriteString ("optional " )
397+ }
394398 g .protoContent .WriteString (fmt .Sprintf ("map<%s, %s> %s = %d;" , keyType , fieldType , name , ele .ID ))
395399
396400 default :
0 commit comments