make MakeTemplate more robust (#60)

This commit is contained in:
Joshua Humphries
2018-10-22 22:59:11 -04:00
committed by GitHub
parent 7cabe7a9d0
commit 1e8e50f4f8
3 changed files with 111 additions and 22 deletions

View File

@@ -15,7 +15,6 @@ import (
"github.com/fullstorydev/grpcurl"
descpb "github.com/golang/protobuf/protoc-gen-go/descriptor"
"github.com/jhump/protoreflect/desc"
"github.com/jhump/protoreflect/dynamic"
"github.com/jhump/protoreflect/grpcreflect"
"golang.org/x/net/context"
"google.golang.org/grpc"
@@ -459,7 +458,7 @@ func main() {
if dsc, ok := dsc.(*desc.MessageDescriptor); ok && *msgTemplate {
// for messages, also show a template in JSON, to make it easier to
// create a request to invoke an RPC
tmpl := grpcurl.MakeTemplate(dynamic.NewMessage(dsc))
tmpl := grpcurl.MakeTemplate(dsc)
_, formatter, err := grpcurl.RequestParserAndFormatterFor(grpcurl.Format(*format), descSource, true, false, nil)
if err != nil {
fail(err, "Failed to construct formatter for %q", *format)