I am debugging the api response which in protobuf format.
I know that I can using the protoc command to make the response readable:
protoc --decode api.Response response.proto < res.bin
It works on the simple files. However, I find that some data is wrapped into the response protobuf like:
// response.proto
...
...
message Response {
int64 status = 1;
google.protobuf.Any detail = 2
...
}
// login.proto
...
...
...
// Import UserDatas protobufs...
message LoginResponse {
string token = 1;
UserDetail user = 2;
UserLastLogin lastlogin = 3;
...
...
...
}
then I run the command
protoc --decode api.Response response.proto < res.bin
I got
status: 200
result {
type_url: "........login",
value: "(very long encoded text without formatting)"
}
I know that I can edit the proto file to change the Any
to the LoginResponse
,and decode it. However I have multiple API protobufs in this format, I cannot edit all the files each time I want to view.
I also ask the developer who using the response, but he told me he just checking the type_url
and using different function to parse the value
data. it looks not good (need to write many functions to handle it, generate the files for all proto and re-generate the library when the proto is updated).
I believe that there are better solutions.
Is there a simpler way to view the response without editing the proto file? (Hope that is able to do on protoc
command or python)