gripmock icon indicating copy to clipboard operation
gripmock copied to clipboard

Support for proto3 `optional`

Open sradevski opened this issue 3 years ago • 5 comments

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

sradevski avatar Apr 15 '21 13:04 sradevski

Extremely need this feature!

isteshkov avatar Oct 11 '21 15:10 isteshkov

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)
        }

malins avatar Dec 30 '21 09:12 malins

Also faced:(

mgerasimchuk avatar Feb 15 '22 12:02 mgerasimchuk

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.

sejin-P avatar May 15 '22 15:05 sejin-P

Looks like PR https://github.com/tokopedia/gripmock/pull/119 is open for this, but unmerged/unreviewed with no comments.

ringerc avatar Apr 18 '23 03:04 ringerc