-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
protobuf.js version: 7.1.2
We are parsing a .proto
file in proto3
format with protobufjs.loadSync
. Using the resulting parsed objects, we need to distinguish between a field that is marked optional
vs. a field that is not marked optional
and also not marked required
. Unfortunately, the protobufjs parser always sets Field.optional
to the value of !Field.required
, so we can't detect the optional
keyword in the parsed Field
object.
We use the Golang protobuf library with the same .proto
file (in proto3
format) which generates different Golang code for fields marked optional
, vs. fields not marked as either optional
or required
. We need to use the protobufjs parser in a similar way.
For example, we would like to detect the difference between the parsed field1
and field2
objects in this .proto
file:
syntax = "proto3";
message Message1 {
string field1 = 1;
optional string field2 = 2;
}