I am trying to create a custom extension that I can use in a custom protoc
compiler I am writing.
I am trying to compiled this protofile:
syntax = "proto3";
import "google/protobuf/descriptor.proto";
extend google.protobuf.MessageOptions {
string my_option = 5123456;
}
message TestMessageRequest {
option (my_option) = "Hello world!";
uint64 value1 = 2;
string value2 = 3;
}
The CodeGeneratorRequest
that my protoc
plugin gets doesn't seem to have this option anywhere. Here is the entire request: Google Drive Link.
Where can I get the value "Hello world!"
for my TestMessageRequest
message?
The option is there in the descriptor of TestMessageRequest
:
"ProtoFile": [
{
"Name": "google/protobuf/descriptor.proto",
....
"HasOptions": true,
}
but because it is an extension field, it does not get converted into JSON.
You should be able to access it the same way that extension fields are accessed in whatever protobuf library you are using. There are examples for a few languages here: Python Protocol Buffer field options