diff --git a/protoc-gen-grpc-gateway/BUILD.bazel b/protoc-gen-grpc-gateway/BUILD.bazel index 5aa586cbe56..28593f41bfc 100644 --- a/protoc-gen-grpc-gateway/BUILD.bazel +++ b/protoc-gen-grpc-gateway/BUILD.bazel @@ -12,6 +12,7 @@ go_library( "//protoc-gen-grpc-gateway/internal/gengateway:go_default_library", "@com_github_golang_glog//:go_default_library", "@org_golang_google_protobuf//compiler/protogen:go_default_library", + "@org_golang_google_protobuf//types/pluginpb:go_default_library", ], ) diff --git a/protoc-gen-grpc-gateway/main.go b/protoc-gen-grpc-gateway/main.go index b838d50fbe7..5c36ee54c46 100644 --- a/protoc-gen-grpc-gateway/main.go +++ b/protoc-gen-grpc-gateway/main.go @@ -18,6 +18,7 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor" "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway/internal/gengateway" "google.golang.org/protobuf/compiler/protogen" + "google.golang.org/protobuf/types/pluginpb" ) var ( @@ -54,6 +55,7 @@ func main() { protogen.Options{ ParamFunc: flag.CommandLine.Set, }.Run(func(gen *protogen.Plugin) error { + gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL) reg := descriptor.NewRegistry() err := applyFlags(reg) diff --git a/protoc-gen-openapiv2/main.go b/protoc-gen-openapiv2/main.go index ebcae17d004..ec0df07f637 100644 --- a/protoc-gen-openapiv2/main.go +++ b/protoc-gen-openapiv2/main.go @@ -146,7 +146,8 @@ func emitFiles(out []*descriptor.ResponseFile) { for idx, item := range out { files[idx] = item.CodeGeneratorResponse_File } - emitResp(&pluginpb.CodeGeneratorResponse{File: files}) + supportedFeatures := uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL) + emitResp(&pluginpb.CodeGeneratorResponse{SupportedFeatures: &supportedFeatures, File: files}) } func emitError(err error) {