From 7b7ae18d8e264d86463cb906ef50207465a59eae Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Thu, 5 Dec 2024 01:06:14 +0300 Subject: [PATCH 1/2] wkt: expanding googleapis support --- example/well_known_types/wkt.proto | 15 ++ go.mod | 6 +- go.sum | 12 +- go.work.sum | 3 + protoc-gen-gripmock/go.mod | 2 +- protoc-gen-gripmock/go.sum | 4 +- protogen/empty.go | 23 +++ protogen/example/well_known_types/wkt.pb.go | 170 +++++++++++++++--- protogen/example/well_known_types/wkt.proto | 15 ++ .../example/well_known_types/wkt_grpc.pb.go | 40 ++++- protogen/go.mod | 7 +- protogen/go.sum | 14 +- 12 files changed, 267 insertions(+), 44 deletions(-) diff --git a/example/well_known_types/wkt.proto b/example/well_known_types/wkt.proto index 28891bcb..5a0dece8 100644 --- a/example/well_known_types/wkt.proto +++ b/example/well_known_types/wkt.proto @@ -5,6 +5,7 @@ package well_known_types; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/api.proto"; +import "google/type/date.proto"; option go_package = "github.com/bavix/gripmock/example/well_known_types;wkt"; service Gripmock { @@ -17,4 +18,18 @@ service Gripmock { body: "*" }; } + + rpc ApiInfoV2 (ApiInfoV2Request) returns (ApiInfoV2Response) { + option (google.api.http) = { + post: "/v2/gripmock/api-info" + body: "*" + }; + } +} + +message ApiInfoV2Request { + string name = 1; + google.type.Date time = 2; } + +message ApiInfoV2Response {} diff --git a/go.mod b/go.mod index a266f13a..c781dbe4 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/rs/zerolog v1.33.0 github.com/spf13/cobra v1.8.1 github.com/stretchr/testify v1.10.0 - google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f + google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a google.golang.org/grpc v1.68.0 google.golang.org/protobuf v1.35.2 ) @@ -45,9 +45,9 @@ require ( github.com/spf13/pflag v1.0.5 // indirect golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect golang.org/x/net v0.31.0 // indirect - golang.org/x/sys v0.27.0 // indirect + golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.20.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index a89797d4..f83882b0 100644 --- a/go.sum +++ b/go.sum @@ -100,14 +100,14 @@ golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= -golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= -google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f h1:M65LEviCfuZTfrfzwwEoxVtgvfkFkBUbFnRbxCXuXhU= -google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f/go.mod h1:Yo94eF2nj7igQt+TiJ49KxjIH8ndLYPZMIRSiRcEbg0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f h1:C1QccEa9kUwvMgEUORqQD9S17QesQijxjZ84sO82mfo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= +google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a h1:OAiGFfOiA0v9MRYsSidp3ubZaBnteRUyn3xB2ZQ5G/E= +google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a/go.mod h1:jehYqy3+AhJU9ve55aNOaSml7wUXjF9x6z2LcCfpAhY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a h1:hgh8P4EuoxpsuKMXX/To36nOFD7vixReXgn8lPGnt+o= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU= google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0= google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA= google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= diff --git a/go.work.sum b/go.work.sum index c4225da3..464f25fe 100644 --- a/go.work.sum +++ b/go.work.sum @@ -348,6 +348,7 @@ golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbht golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= @@ -395,8 +396,10 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61/go. google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU= google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= diff --git a/protoc-gen-gripmock/go.mod b/protoc-gen-gripmock/go.mod index 19893191..309dccbc 100644 --- a/protoc-gen-gripmock/go.mod +++ b/protoc-gen-gripmock/go.mod @@ -10,5 +10,5 @@ require ( require ( golang.org/x/mod v0.22.0 // indirect - golang.org/x/sync v0.9.0 // indirect + golang.org/x/sync v0.10.0 // indirect ) diff --git a/protoc-gen-gripmock/go.sum b/protoc-gen-gripmock/go.sum index 7bc71c98..0296e4d6 100644 --- a/protoc-gen-gripmock/go.sum +++ b/protoc-gen-gripmock/go.sum @@ -2,8 +2,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= -golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= -golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o= diff --git a/protogen/empty.go b/protogen/empty.go index 356b3890..194a4584 100644 --- a/protogen/empty.go +++ b/protogen/empty.go @@ -1 +1,24 @@ package protogen + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + _ "google.golang.org/genproto/googleapis/type/calendarperiod" + _ "google.golang.org/genproto/googleapis/type/color" + _ "google.golang.org/genproto/googleapis/type/date" + _ "google.golang.org/genproto/googleapis/type/date_range" + _ "google.golang.org/genproto/googleapis/type/date_time_range" + _ "google.golang.org/genproto/googleapis/type/datetime" + _ "google.golang.org/genproto/googleapis/type/dayofweek" + _ "google.golang.org/genproto/googleapis/type/decimal" + _ "google.golang.org/genproto/googleapis/type/expr" + _ "google.golang.org/genproto/googleapis/type/fraction" + _ "google.golang.org/genproto/googleapis/type/interval" + _ "google.golang.org/genproto/googleapis/type/latlng" + _ "google.golang.org/genproto/googleapis/type/localized_text" + _ "google.golang.org/genproto/googleapis/type/money" + _ "google.golang.org/genproto/googleapis/type/month" + _ "google.golang.org/genproto/googleapis/type/phone_number" + _ "google.golang.org/genproto/googleapis/type/postaladdress" + _ "google.golang.org/genproto/googleapis/type/quaternion" + _ "google.golang.org/genproto/googleapis/type/timeofday" +) diff --git a/protogen/example/well_known_types/wkt.pb.go b/protogen/example/well_known_types/wkt.pb.go index 8f535212..834ff2e3 100644 --- a/protogen/example/well_known_types/wkt.pb.go +++ b/protogen/example/well_known_types/wkt.pb.go @@ -8,11 +8,13 @@ package well_known_types import ( _ "google.golang.org/genproto/googleapis/api/annotations" + date "google.golang.org/genproto/googleapis/type/date" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" apipb "google.golang.org/protobuf/types/known/apipb" emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" + sync "sync" ) const ( @@ -22,6 +24,95 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type ApiInfoV2Request struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Time *date.Date `protobuf:"bytes,2,opt,name=time,proto3" json:"time,omitempty"` +} + +func (x *ApiInfoV2Request) Reset() { + *x = ApiInfoV2Request{} + mi := &file_wkt_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ApiInfoV2Request) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApiInfoV2Request) ProtoMessage() {} + +func (x *ApiInfoV2Request) ProtoReflect() protoreflect.Message { + mi := &file_wkt_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ApiInfoV2Request.ProtoReflect.Descriptor instead. +func (*ApiInfoV2Request) Descriptor() ([]byte, []int) { + return file_wkt_proto_rawDescGZIP(), []int{0} +} + +func (x *ApiInfoV2Request) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ApiInfoV2Request) GetTime() *date.Date { + if x != nil { + return x.Time + } + return nil +} + +type ApiInfoV2Response struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ApiInfoV2Response) Reset() { + *x = ApiInfoV2Response{} + mi := &file_wkt_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ApiInfoV2Response) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApiInfoV2Response) ProtoMessage() {} + +func (x *ApiInfoV2Response) ProtoReflect() protoreflect.Message { + mi := &file_wkt_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ApiInfoV2Response.ProtoReflect.Descriptor instead. +func (*ApiInfoV2Response) Descriptor() ([]byte, []int) { + return file_wkt_proto_rawDescGZIP(), []int{1} +} + var File_wkt_proto protoreflect.FileDescriptor var file_wkt_proto_rawDesc = []byte{ @@ -32,32 +123,66 @@ var file_wkt_proto_rawDesc = []byte{ 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x32, 0x65, 0x0a, 0x08, 0x47, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x12, - 0x59, 0x0a, 0x07, 0x41, 0x70, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, - 0x74, 0x79, 0x1a, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x70, 0x69, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, - 0x3a, 0x01, 0x2a, 0x22, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, - 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2d, 0x69, 0x6e, 0x66, 0x6f, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x76, 0x69, 0x78, 0x2f, 0x67, - 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, - 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x77, 0x65, 0x6c, 0x6c, 0x5f, 0x6b, 0x6e, - 0x6f, 0x77, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x74, 0x79, 0x70, 0x65, + 0x2f, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x4d, 0x0a, 0x10, 0x41, + 0x70, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x56, 0x32, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x11, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, + 0x44, 0x61, 0x74, 0x65, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x13, 0x0a, 0x11, 0x41, 0x70, + 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x56, 0x32, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, + 0xdd, 0x01, 0x0a, 0x08, 0x47, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x12, 0x59, 0x0a, 0x07, + 0x41, 0x70, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, + 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x41, 0x70, 0x69, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x3a, 0x01, 0x2a, + 0x22, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x61, + 0x70, 0x69, 0x2d, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x76, 0x0a, 0x09, 0x41, 0x70, 0x69, 0x49, 0x6e, + 0x66, 0x6f, 0x56, 0x32, 0x12, 0x22, 0x2e, 0x77, 0x65, 0x6c, 0x6c, 0x5f, 0x6b, 0x6e, 0x6f, 0x77, + 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x41, 0x70, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x56, + 0x32, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x77, 0x65, 0x6c, 0x6c, 0x5f, + 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x41, 0x70, 0x69, 0x49, + 0x6e, 0x66, 0x6f, 0x56, 0x32, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x3a, 0x01, 0x2a, 0x22, 0x15, 0x2f, 0x76, 0x32, 0x2f, 0x67, 0x72, + 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2d, 0x69, 0x6e, 0x66, 0x6f, 0x42, + 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, + 0x76, 0x69, 0x78, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x77, 0x65, + 0x6c, 0x6c, 0x5f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_wkt_proto_rawDescOnce sync.Once + file_wkt_proto_rawDescData = file_wkt_proto_rawDesc +) + +func file_wkt_proto_rawDescGZIP() []byte { + file_wkt_proto_rawDescOnce.Do(func() { + file_wkt_proto_rawDescData = protoimpl.X.CompressGZIP(file_wkt_proto_rawDescData) + }) + return file_wkt_proto_rawDescData } +var file_wkt_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_wkt_proto_goTypes = []any{ - (*emptypb.Empty)(nil), // 0: google.protobuf.Empty - (*apipb.Api)(nil), // 1: google.protobuf.Api + (*ApiInfoV2Request)(nil), // 0: well_known_types.ApiInfoV2Request + (*ApiInfoV2Response)(nil), // 1: well_known_types.ApiInfoV2Response + (*date.Date)(nil), // 2: google.type.Date + (*emptypb.Empty)(nil), // 3: google.protobuf.Empty + (*apipb.Api)(nil), // 4: google.protobuf.Api } var file_wkt_proto_depIdxs = []int32{ - 0, // 0: well_known_types.Gripmock.ApiInfo:input_type -> google.protobuf.Empty - 1, // 1: well_known_types.Gripmock.ApiInfo:output_type -> google.protobuf.Api - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 2, // 0: well_known_types.ApiInfoV2Request.time:type_name -> google.type.Date + 3, // 1: well_known_types.Gripmock.ApiInfo:input_type -> google.protobuf.Empty + 0, // 2: well_known_types.Gripmock.ApiInfoV2:input_type -> well_known_types.ApiInfoV2Request + 4, // 3: well_known_types.Gripmock.ApiInfo:output_type -> google.protobuf.Api + 1, // 4: well_known_types.Gripmock.ApiInfoV2:output_type -> well_known_types.ApiInfoV2Response + 3, // [3:5] is the sub-list for method output_type + 1, // [1:3] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_wkt_proto_init() } @@ -71,12 +196,13 @@ func file_wkt_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_wkt_proto_rawDesc, NumEnums: 0, - NumMessages: 0, + NumMessages: 2, NumExtensions: 0, NumServices: 1, }, GoTypes: file_wkt_proto_goTypes, DependencyIndexes: file_wkt_proto_depIdxs, + MessageInfos: file_wkt_proto_msgTypes, }.Build() File_wkt_proto = out.File file_wkt_proto_rawDesc = nil diff --git a/protogen/example/well_known_types/wkt.proto b/protogen/example/well_known_types/wkt.proto index 647f296a..1f0f3beb 100644 --- a/protogen/example/well_known_types/wkt.proto +++ b/protogen/example/well_known_types/wkt.proto @@ -5,6 +5,7 @@ package well_known_types; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/api.proto"; +import "google/type/date.proto"; option go_package = "github.com/bavix/gripmock/protogen/example/well_known_types"; service Gripmock { @@ -17,4 +18,18 @@ service Gripmock { body: "*" }; } + + rpc ApiInfoV2 (ApiInfoV2Request) returns (ApiInfoV2Response) { + option (google.api.http) = { + post: "/v2/gripmock/api-info" + body: "*" + }; + } +} + +message ApiInfoV2Request { + string name = 1; + google.type.Date time = 2; } + +message ApiInfoV2Response {} diff --git a/protogen/example/well_known_types/wkt_grpc.pb.go b/protogen/example/well_known_types/wkt_grpc.pb.go index 6c4eb764..179ee688 100644 --- a/protogen/example/well_known_types/wkt_grpc.pb.go +++ b/protogen/example/well_known_types/wkt_grpc.pb.go @@ -21,7 +21,8 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - Gripmock_ApiInfo_FullMethodName = "/well_known_types.Gripmock/ApiInfo" + Gripmock_ApiInfo_FullMethodName = "/well_known_types.Gripmock/ApiInfo" + Gripmock_ApiInfoV2_FullMethodName = "/well_known_types.Gripmock/ApiInfoV2" ) // GripmockClient is the client API for Gripmock service. @@ -32,6 +33,7 @@ type GripmockClient interface { // api.proto in particular has go_package alias with semicolon // "google.golang.org/genproto/protobuf/api;api" ApiInfo(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*apipb.Api, error) + ApiInfoV2(ctx context.Context, in *ApiInfoV2Request, opts ...grpc.CallOption) (*ApiInfoV2Response, error) } type gripmockClient struct { @@ -52,6 +54,16 @@ func (c *gripmockClient) ApiInfo(ctx context.Context, in *emptypb.Empty, opts .. return out, nil } +func (c *gripmockClient) ApiInfoV2(ctx context.Context, in *ApiInfoV2Request, opts ...grpc.CallOption) (*ApiInfoV2Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ApiInfoV2Response) + err := c.cc.Invoke(ctx, Gripmock_ApiInfoV2_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // GripmockServer is the server API for Gripmock service. // All implementations must embed UnimplementedGripmockServer // for forward compatibility. @@ -60,6 +72,7 @@ type GripmockServer interface { // api.proto in particular has go_package alias with semicolon // "google.golang.org/genproto/protobuf/api;api" ApiInfo(context.Context, *emptypb.Empty) (*apipb.Api, error) + ApiInfoV2(context.Context, *ApiInfoV2Request) (*ApiInfoV2Response, error) mustEmbedUnimplementedGripmockServer() } @@ -73,6 +86,9 @@ type UnimplementedGripmockServer struct{} func (UnimplementedGripmockServer) ApiInfo(context.Context, *emptypb.Empty) (*apipb.Api, error) { return nil, status.Errorf(codes.Unimplemented, "method ApiInfo not implemented") } +func (UnimplementedGripmockServer) ApiInfoV2(context.Context, *ApiInfoV2Request) (*ApiInfoV2Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method ApiInfoV2 not implemented") +} func (UnimplementedGripmockServer) mustEmbedUnimplementedGripmockServer() {} func (UnimplementedGripmockServer) testEmbeddedByValue() {} @@ -112,6 +128,24 @@ func _Gripmock_ApiInfo_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Gripmock_ApiInfoV2_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ApiInfoV2Request) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GripmockServer).ApiInfoV2(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Gripmock_ApiInfoV2_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GripmockServer).ApiInfoV2(ctx, req.(*ApiInfoV2Request)) + } + return interceptor(ctx, in, info, handler) +} + // Gripmock_ServiceDesc is the grpc.ServiceDesc for Gripmock service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -123,6 +157,10 @@ var Gripmock_ServiceDesc = grpc.ServiceDesc{ MethodName: "ApiInfo", Handler: _Gripmock_ApiInfo_Handler, }, + { + MethodName: "ApiInfoV2", + Handler: _Gripmock_ApiInfoV2_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "wkt.proto", diff --git a/protogen/go.mod b/protogen/go.mod index 3ebeb85a..8444f737 100644 --- a/protogen/go.mod +++ b/protogen/go.mod @@ -3,14 +3,15 @@ module github.com/bavix/gripmock/protogen go 1.23.2 require ( - google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f + google.golang.org/genproto v0.0.0-20241202173237-19429a94021a + google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a google.golang.org/grpc v1.68.0 google.golang.org/protobuf v1.35.2 ) require ( golang.org/x/net v0.31.0 // indirect - golang.org/x/sys v0.27.0 // indirect + golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.20.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect ) diff --git a/protogen/go.sum b/protogen/go.sum index 490663e4..f96c2738 100644 --- a/protogen/go.sum +++ b/protogen/go.sum @@ -4,14 +4,16 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= -golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= -golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= -google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f h1:M65LEviCfuZTfrfzwwEoxVtgvfkFkBUbFnRbxCXuXhU= -google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f/go.mod h1:Yo94eF2nj7igQt+TiJ49KxjIH8ndLYPZMIRSiRcEbg0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f h1:C1QccEa9kUwvMgEUORqQD9S17QesQijxjZ84sO82mfo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= +google.golang.org/genproto v0.0.0-20241202173237-19429a94021a h1:4voejwOVTsjw6IMfnGt8IzTQBIw45hP8S0e77UMounA= +google.golang.org/genproto v0.0.0-20241202173237-19429a94021a/go.mod h1:dW27OyXi0Ph+N43jeCWMFC86aTT5VgdeQtOSf0Hehdw= +google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a h1:OAiGFfOiA0v9MRYsSidp3ubZaBnteRUyn3xB2ZQ5G/E= +google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a/go.mod h1:jehYqy3+AhJU9ve55aNOaSml7wUXjF9x6z2LcCfpAhY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a h1:hgh8P4EuoxpsuKMXX/To36nOFD7vixReXgn8lPGnt+o= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU= google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0= google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA= google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= From 347c0286efb8e6ba1a8e332cf9c50e7b0fb56ca6 Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Thu, 5 Dec 2024 01:06:31 +0300 Subject: [PATCH 2/2] work sync --- go.mod | 1 + go.sum | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index c781dbe4..59ca3d4b 100644 --- a/go.mod +++ b/go.mod @@ -45,6 +45,7 @@ require ( github.com/spf13/pflag v1.0.5 // indirect golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect golang.org/x/net v0.31.0 // indirect + golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.20.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect diff --git a/go.sum b/go.sum index f83882b0..93642937 100644 --- a/go.sum +++ b/go.sum @@ -95,8 +95,7 @@ golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+h golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak= golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= -golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= -golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=