Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gengapic): document client/bidi streaming unsupported in REST #1181

Merged
merged 1 commit into from Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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