Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define int in proto but got string #323

Closed
anotherGoogleFan opened this issue Jan 15, 2021 · 3 comments
Closed

Define int in proto but got string #323

anotherGoogleFan opened this issue Jan 15, 2021 · 3 comments

Comments

@anotherGoogleFan
Copy link

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
Copy link
Author

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

@zwiedmann-isp
Copy link
Contributor

zwiedmann-isp commented Jan 18, 2021 via email

@anotherGoogleFan
Copy link
Author

Thanks a lot. That solve my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants