The enum type under proto3 will report an error.
The enum type under proto3 will report an error.
Error: Error while parsing the JSON representation of the protobuf message:
Expected 'number', but got 'string'
Hmm that's strange. To best of my knowledge, enum values in protobuf are serialized as numbers rather than strings. Could you provide me a snippet of the .proto file and how you're constructing your message?
I have two .proto file
backend/server/status/get.proto
syntax = "proto3";
package backend.server.status;
option go_package = "backend/app/pb/server/status";
import "backend/public/responseHead.proto";
import "backend/public/platform.proto";
message GetResponse {
backend.public.ResponseHead head = 1;
backend.public.Platform platform = 2;
}
backend/public/platform.proto
syntax = "proto3";
package backend.public;
option go_package = "backend/app/pb/public";
enum Platform {
PLATFORM_EMAIL = 0;
PLATFORM_WXMINI = 1;
PLATFORM_WXH5 = 2;
PLATFORM_MOBILE = 3;
}
An error occurred on the platform in GetResponse
Hmm that's strange. I'll double check to see what's going on. Thank you!
@spluxx any updates on this ? I am facing the same issue.
Same here
@spluxx any updates on this ? I am facing the same issue.
got the solution?
I'm running into this issue too (v0.4.0 on Windows 10). Even an enum with a single option will cause issues:
syntax = "proto3";
package enumtest;
message MyObject {
enum MessageType {
MY_MESSAGE_TYPE = 0;
}
MessageType message_type = 1;
}
Here I encoded { messageType: 0 }:

I noticed if messageType is out of range, it will use the enum default (here MY_MESSAGE_TYPE) with no error. Here I encoded { messageType: 15 }:

Going to look into this a bit later, but at least the data can be verified in the readout window below the error message for now.