protobuf.js
protobuf.js copied to clipboard
protobufjs 70code generation with custom option broken
protobuf.js version: 7.0.0
I'm trying to upgrade protobufjs from 6.11.3 to 7.0.0. but found code generation is broken on custom options.
here is a simplified example of .proto with custom options
syntax = "proto3";
package person;
import "google/protobuf/descriptor.proto";
/**
* Data structure for defining constraints on message fields
*/
message Constraints {
message IntegerRange {
int64 low = 1;
int64 high = 2;
}
bool isMandatory = 1;
IntegerRange integerRange = 2;
}
extend google.protobuf.FieldOptions {
Constraints constraints = 50000;
}
message Person {
int64 id = 1 [(constraints) = { isMandatory: true }];
string name = 2;
int64 birthday = 3 [(constraints) = { isMandatory: true, integerRange: {low: 0, high: 4102448400000 } }];
}
and the command used for code generation
npx pbjs -t static-module -w commonjs -o src/gen/message.js model/person.proto && npx pbts -o src/gen/message.d.ts src/gen/message.js
With protobufjs 7.0.0, the code generation fails with the following error :
npx: installed 3 in 4.39s
Unexpected token in field options: isMandatory
it looks like the custom option feature has backward compatibility issue .
Could you help please ?