Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(gengapic): document client/bidi streaming unsupported in REST (#1181
)
  • Loading branch information
noahdietz committed Nov 8, 2022
1 parent 6194925 commit f9a9191
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions internal/gengapic/gengapic.go
Expand Up @@ -479,6 +479,9 @@ func (g *generator) methodDoc(m *descriptor.MethodDescriptorProto) {
return
}

if containsTransport(g.opts.transports, rest) && m.GetClientStreaming() {
com = fmt.Sprintf("%s\n\nThis method is not supported for the REST transport.", com)
}
// If the method is marked as deprecated and there is no comment, then add default deprecation comment.
// If the method has a comment but it does not include a deprecation notice, then append a default deprecation notice.
// If the method includes a deprecation notice at the beginning of the comment, prepend a comment stating the method is deprecated and use the included deprecation notice.
Expand Down
13 changes: 11 additions & 2 deletions internal/gengapic/gengapic_test.go
Expand Up @@ -564,8 +564,9 @@ func TestMethodDoc(t *testing.T) {
}

for _, tst := range []struct {
in, want string
deprecated bool
in, want string
clientStreaming, deprecated bool
opts options
}{
{
in: "",
Expand Down Expand Up @@ -595,11 +596,19 @@ func TestMethodDoc(t *testing.T) {
want: "// MyMethod is deprecated.\n//\n// Deprecated: MyMethod may be removed in a future version.\n",
deprecated: true,
},
{
in: "Does client streaming stuff.\n It also does other stuffs.",
want: "// MyMethod does client streaming stuff.\n// It also does other stuffs.\n//\n// This method is not supported for the REST transport.\n",
clientStreaming: true,
opts: options{transports: []transport{rest}},
},
} {
g.opts = &tst.opts
g.comments[m] = tst.in
m.Options = &descriptor.MethodOptions{
Deprecated: proto.Bool(tst.deprecated),
}
m.ClientStreaming = proto.Bool(tst.clientStreaming)
g.pt.Reset()
g.methodDoc(m)
if diff := cmp.Diff(g.pt.String(), tst.want); diff != "" {
Expand Down

0 comments on commit f9a9191

Please sign in to comment.