metaverse / truss

Truss helps you build go-kit microservices without having to worry about writing or maintaining boilerplate code.
Other
734 stars 143 forks source link

Define int in proto but got string #323

Closed anotherGoogleFan closed 3 years ago

anotherGoogleFan commented 3 years ago

My proto is like this:

syntax = "proto3";

package prototest;

option go_package = ".;prototest";

import "github.com/metaverse/truss/deftree/googlethirdparty/annotations.proto";

service Test {
    rpc Add1(add1Request) returns(Add1Response){
        option (google.api.http) = {
            post: "/add_1"
            body: "*"
        };  
    }
}

message add1Request{
    uint64 ori = 1;
}

message Add1Response{
    uint64 ans = 2;
}

AND I post a request: HTTP POST: http://127.0.0.1:5050/add_1

{
    "ori": 15
}

I got the response like this:

{
    "ans": "16"
}

but in proto file, I define ans is an int, not string. I think the response should be like this:

{
    "ans": 16
}
anotherGoogleFan commented 3 years ago

I tried many times and found that it seems like a bug in github.com/gogo/protobuf/jsonpb. I raise an issue: https://github.com/gogo/protobuf/issues/718

zwiedmann-isp commented 3 years ago

hey sorry for the delay, we have a fork of jsonpb in github.com/metaverse/protobuf -- in my projects i simply use modules to replace the import and thatll make your int64s numbers again.

On Sun, Jan 17, 2021, 6:05 PM HuangTao notifications@github.com wrote:

I tried many times and found that it seems like a bug in github.com/gogo/protobuf/jsonpb. I raise an issue: gogo/protobuf#718 https://github.com/gogo/protobuf/issues/718

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/metaverse/truss/issues/323#issuecomment-761932953, or unsubscribe https://github.com/notifications/unsubscribe-auth/APUUNDVNZ2FYIKKTHEOJFULS2OJQJANCNFSM4WD2VZHA .

anotherGoogleFan commented 3 years ago

Thanks a lot. That solve my problem.