Fixed incorrect interface nil check in protoc-gen-openapi (#249) The `annotation` variable is an interface and was only checked for `nil`, but not if `nil` would be assigned to the interface. This lead to a crash, if a method within a service was not annotated at all. Closes #248
diff --git a/apps/protoc-gen-openapi/generator/openapi-v3.go b/apps/protoc-gen-openapi/generator/openapi-v3.go index f022312..4211c97 100644 --- a/apps/protoc-gen-openapi/generator/openapi-v3.go +++ b/apps/protoc-gen-openapi/generator/openapi-v3.go
@@ -127,11 +127,12 @@ inputMessage := method.Input outputMessage := method.Output operationID := service.GoName + "_" + method.GoName - extension := proto.GetExtension(method.Desc.Options(), annotations.E_Http) + xt := annotations.E_Http + extension := proto.GetExtension(method.Desc.Options(), xt) var path string var methodName string var body string - if extension != nil { + if extension != nil && extension != xt.InterfaceOf(xt.Zero()) { rule := extension.(*annotations.HttpRule) body = rule.Body switch pattern := rule.Pattern.(type) {