From 805da79319a4b84b5d2a8a0c6f2234ff37f55acd Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 1 Oct 2024 09:42:40 +0300 Subject: [PATCH] [#120] protogen: Marshal enum as string Be compatible with protojson. Signed-off-by: Evgenii Stratonikov --- acl/grpc/types_frostfs.pb.go | Bin 45143 -> 45546 bytes ape/grpc/types_frostfs.pb.go | Bin 8228 -> 8311 bytes netmap/grpc/types_frostfs.pb.go | Bin 52857 -> 53105 bytes object/grpc/service_frostfs.pb.go | Bin 214426 -> 214688 bytes object/grpc/types_frostfs.pb.go | Bin 59835 -> 60001 bytes refs/grpc/types_frostfs.pb.go | Bin 28639 -> 28812 bytes session/grpc/types_frostfs.pb.go | Bin 65790 -> 65989 bytes util/proto/test/custom/test_frostfs.pb.go | Bin 30142 -> 30234 bytes util/protogen/internalgengo/json.go | 8 +++++++- 9 files changed, 7 insertions(+), 1 deletion(-) diff --git a/acl/grpc/types_frostfs.pb.go b/acl/grpc/types_frostfs.pb.go index 2b116bdd94b0cc98da542c54d633d38f03da918f..b05516737beddc2861e9f80603982be38073224c 100644 GIT binary patch delta 626 zcmccqfa%p^rVVxS^<@fHwhEbfCB{Y?6?z`2i7BZ?A(aKGnp~WmnQ01TWjYG^*&rnd zsrbCa+|=l@SZk0>HBcRAerbtba7j^SUb;qE8AxZXLTXNNDnil|Y(7Mai?f!C6QnIU zKd-oCGH;XUI}FHRb8P_Fqywec(b~KvtTMpfCS~|U@ywosM6xHAU1*t`eC7Jno7{L#hq0nN~(1-YYvX#54D2lfolOc|nyunv&@_k-b OOR{4d?9n;yyE6a{L%b9K delta 147 zcmaF$nCbchrVVxST=}IXdY*YD#zq>G{YAtkPia=1ETo_@*}#j14J!OlOk(o%X1UF0 z6r2Uc5y~^cnkw{y@^ex(Cr@lv**x7SR212~ep|4{$#ov8AoD~a=E3wiCYNO9=RtJp Id+yEv0REOUQ~&?~ diff --git a/ape/grpc/types_frostfs.pb.go b/ape/grpc/types_frostfs.pb.go index 216415b4b19839a62fa3c943b46df48c1420289f..e19d9f6938d731c90940454591fbd696d4c0ebb0 100644 GIT binary patch delta 99 zcmZ4D@ZDiUB%g4Zf|ad8W?qT0kw%4HNM%8)CfDQ|K`Fbu#N5>AvRG?{{A`74E>2F) m{L&J=;F6-uymXDSGEJaJtwL%}aVkR66Kn`XYI7mqWUgjEyuh!DNM=e}U%YhXyK}?@L;Ufuu!IrJZvUON&z> YN){XBMPgABT#{Ils;RlTvFn2i0LPpqN&o-= diff --git a/object/grpc/service_frostfs.pb.go b/object/grpc/service_frostfs.pb.go index dea1b5b79b5780876f1247863d681ceb40b7facc..188d03265c90e43f2717587aa20d6d01656366be 100644 GIT binary patch delta 345 zcmbQ$&AXtNw_yw8gg%Kf1uI*H%)Am~BaI3@-^7ySjF8HLR86kw`jZ$X?eY?HQ=`jb ztrhaK6{@*7IXUx7OZ0+EiZb)kHOk5~fg-gEsX4`|2uV+{Q4p!gj+x5aFZ3}oo)$*2 z25Q6kRwhMDvTc}do5GkpJ)oJ1Z~B2?CZ6f%e=~7TH&9{BpFAOuWx7EqlNeZN^M>17 W7`JbTVG2;i=?H3g)4GW%{xATpPi(>f delta 141 zcmZ3`%R8%^w_yw8gg&nP(h@z-yb@z0jp_GW7)2*vQB>Tn)X&IxdisY5CKh3cR3=zK zgz(NK2wv6H-}# Uuq1(9ngUBE`l)Q@%D&110K7mwaR2}S delta 81 zcmeBq$aw!g;|6Pg$^6n1J>8G3vDOOt*$UM_ zG0yzb620J(qRhN>jj}S3s#=BAoZ?i3q$k)Eh}7hRYm_%%ROJ&F#$v(b%?>(td5O8H M(Uh4lW&7kX0AbEP2mk;8 delta 57 xcmX@w%<`|1Wy3U8uKdyxJ9(#tlN|llx7$1TynVjEyuZ^xQI2b5cAsH8*#dPqG65_6iKy diff --git a/util/protogen/internalgengo/json.go b/util/protogen/internalgengo/json.go index f7cd284d..95a06d59 100644 --- a/util/protogen/internalgengo/json.go +++ b/util/protogen/internalgengo/json.go @@ -195,7 +195,13 @@ func emitJSONFieldWrite(g *protogen.GeneratedFile, f *protogen.Field, name strin case protoreflect.BoolKind: template = "out.Bool(%s)" case protoreflect.EnumKind: - template = "out.Int32(int32(%s))" + enumType := fieldType(g, f).String() + template = `v := int32(%s) + if vv, ok := ` + enumType + `_name[v]; ok { + out.String(vv) + } else { + out.Int32(v) + }` case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: template = "out.Int32(%s)" case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: