From 82b83c7813fb2b597b03f4abaf56fb2cb33b74ab Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Wed, 27 Sep 2017 11:36:38 +0100 Subject: [PATCH] protoc-gen-swagger optional SourceCodeInfo --- protoc-gen-swagger/genswagger/template.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index b2353aa5341..a7ef682ea8b 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "fmt" + "os" "reflect" "regexp" "strconv" @@ -722,13 +723,8 @@ func enumValueProtoComments(reg *descriptor.Registry, enum *descriptor.Enum) str func protoComments(reg *descriptor.Registry, file *descriptor.File, outers []string, typeName string, typeIndex int32, fieldPaths ...int32) string { if file.SourceCodeInfo == nil { - // Curious! A file without any source code info. - // This could be a test that's providing incomplete - // descriptor.File information. - // - // We could simply return no comments, but panic - // could make debugging easier. - panic("descriptor.File should not contain nil SourceCodeInfo") + fmt.Fprintln(os.Stderr, "descriptor.File should not contain nil SourceCodeInfo") + return "" } outerPaths := make([]int32, len(outers))