Skip to content

Commit

Permalink
fix(gengapic): extraneous protojson import (#1196)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahdietz committed Dec 7, 2022
1 parent 1ecf31e commit 023fed2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/gengapic/genrest.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ func (g *generator) serverStreamRESTCall(servName string, s *descriptor.ServiceD

body = "bytes.NewReader(jsonReq)"
g.imports[pbinfo.ImportSpec{Path: "bytes"}] = true
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/protobuf/encoding/protojson"}] = true
}

g.generateBaseURL(info, "return nil, err")
Expand Down Expand Up @@ -683,7 +684,6 @@ func (g *generator) serverStreamRESTCall(servName string, s *descriptor.ServiceD
p("")

g.imports[pbinfo.ImportSpec{Path: "google.golang.org/api/googleapi"}] = true
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/protobuf/encoding/protojson"}] = true

// server-stream wrapper client
p("// %s is the stream client used to consume the server stream created by", streamClient)
Expand Down Expand Up @@ -1146,6 +1146,8 @@ func (g *generator) unaryRESTCall(servName string, m *descriptor.MethodDescripto

body = "bytes.NewReader(jsonReq)"
g.imports[pbinfo.ImportSpec{Path: "bytes"}] = true
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/protobuf/encoding/protojson"}] = true

}

g.generateBaseURL(info, "return nil, err")
Expand All @@ -1155,6 +1157,8 @@ func (g *generator) unaryRESTCall(servName string, m *descriptor.MethodDescripto
g.appendCallOpts(m)
if !isHTTPBodyMessage {
p("unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}")
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/protobuf/encoding/protojson"}] = true

}
p("resp := &%s.%s{}", outSpec.Name, outType.GetName())
p("e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {")
Expand Down Expand Up @@ -1211,7 +1215,6 @@ func (g *generator) unaryRESTCall(servName string, m *descriptor.MethodDescripto

g.imports[pbinfo.ImportSpec{Path: "io/ioutil"}] = true
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/api/googleapi"}] = true
g.imports[pbinfo.ImportSpec{Path: "google.golang.org/protobuf/encoding/protojson"}] = true
g.imports[inSpec] = true
g.imports[outSpec] = true
return nil
Expand Down

0 comments on commit 023fed2

Please sign in to comment.