[#120] protogen: Marshal enum as string

Be compatible with protojson.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-10-01 09:42:40 +03:00
parent f812b1ae5b
commit 805da79319
9 changed files with 121 additions and 20 deletions

View file

@ -4117,7 +4117,12 @@ func (x *SearchRequest_Body_Filter) MarshalEasyJSON(out *jwriter.Writer) {
{
const prefix string = ",\"matchType\":"
out.RawString(prefix[1:])
out.Int32(int32(x.MatchType))
v := int32(x.MatchType)
if vv, ok := MatchType_name[v]; ok {
out.String(vv)
} else {
out.Int32(v)
}
}
{
const prefix string = ",\"key\":"
@ -6246,7 +6251,12 @@ func (x *GetRangeHashRequest_Body) MarshalEasyJSON(out *jwriter.Writer) {
{
const prefix string = ",\"type\":"
out.RawString(prefix)
out.Int32(int32(x.Type))
v := int32(x.Type)
if vv, ok := grpc.ChecksumType_name[v]; ok {
out.String(vv)
} else {
out.Int32(v)
}
}
out.RawByte('}')
}
@ -6659,7 +6669,12 @@ func (x *GetRangeHashResponse_Body) MarshalEasyJSON(out *jwriter.Writer) {
{
const prefix string = ",\"type\":"
out.RawString(prefix[1:])
out.Int32(int32(x.Type))
v := int32(x.Type)
if vv, ok := grpc.ChecksumType_name[v]; ok {
out.String(vv)
} else {
out.Int32(v)
}
}
{
const prefix string = ",\"hashList\":"

View file

@ -323,7 +323,12 @@ func (x *ShortHeader) MarshalEasyJSON(out *jwriter.Writer) {
{
const prefix string = ",\"objectType\":"
out.RawString(prefix)
out.Int32(int32(x.ObjectType))
v := int32(x.ObjectType)
if vv, ok := ObjectType_name[v]; ok {
out.String(vv)
} else {
out.Int32(v)
}
}
{
const prefix string = ",\"payloadLength\":"
@ -1659,7 +1664,12 @@ func (x *Header) MarshalEasyJSON(out *jwriter.Writer) {
{
const prefix string = ",\"objectType\":"
out.RawString(prefix)
out.Int32(int32(x.ObjectType))
v := int32(x.ObjectType)
if vv, ok := ObjectType_name[v]; ok {
out.String(vv)
} else {
out.Int32(v)
}
}
{
const prefix string = ",\"homomorphicHash\":"