gripmock
gripmock copied to clipboard
Support for proto3 `optional`
Hey there, great job on making this, it is much needed.
I tried using the package, but it seems optional
is not supported. When running the package, I get This file contains proto3 optional fields, but --experimental_allow_proto3_optional was not set.
, so maybe it's as simple as passing the experimental flag to proto-gen
?
Cheers
Extremely need this feature!
Just patch generator.go to also support optional keyword in proto files.
diff --git a/protoc-gen-gripmock/generator.go b/protoc-gen-gripmock/generator.go
index cdd2258..5cb63b6 100644
--- a/protoc-gen-gripmock/generator.go
+++ b/protoc-gen-gripmock/generator.go
@@ -34,6 +34,7 @@ func main() {
// Initialise our plugin with default options
opts := protogen.Options{}
plugin, err := opts.New(&request)
+ plugin.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
if err != nil {
log.Fatalf("error initializing plugin: %v", err)
}
Also faced:(
It's because of protoc in gripmock image is 3.12.2 which cannot support optional field. I tried to fix it, but all of my effort was unnecessary.
Looks like PR https://github.com/tokopedia/gripmock/pull/119 is open for this, but unmerged/unreviewed with no comments.