diff --git a/net/ghttp/ghttp_server_openapi.go b/net/ghttp/ghttp_server_openapi.go index 5759aa5c1..abcdb0fcf 100644 --- a/net/ghttp/ghttp_server_openapi.go +++ b/net/ghttp/ghttp_server_openapi.go @@ -7,6 +7,7 @@ package ghttp import ( + "context" "github.com/gogf/gf/internal/intlog" "github.com/gogf/gf/protocol/goai" "github.com/gogf/gf/text/gstr" @@ -18,6 +19,7 @@ func (s *Server) initOpenApi() { return } var ( + ctx = context.TODO() err error method string ) @@ -37,7 +39,7 @@ func (s *Server) initOpenApi() { Object: item.Handler.Info.Value.Interface(), }) if err != nil { - panic(err) + s.Logger().Fatalf(ctx, `%+v`, err) } } } diff --git a/protocol/goai/goai_parameter.go b/protocol/goai/goai_parameter.go index a42916275..90fe10669 100644 --- a/protocol/goai/goai_parameter.go +++ b/protocol/goai/goai_parameter.go @@ -59,7 +59,7 @@ func (oai *OpenApiV3) newParameterRefWithStructMethod(field *structs.Field) (*Pa if len(tagMap) > 0 { err := gconv.Struct(tagMap, parameter) if err != nil { - return nil, gerror.WrapCodef(gcode.CodeInternalError, err, `mapping struct tags to Parameter failed`) + return nil, gerror.WrapCode(gcode.CodeInternalError, err, `mapping struct tags to Parameter failed`) } } // Required for path parameter. diff --git a/protocol/goai/goai_path.go b/protocol/goai/goai_path.go index e6f9c933e..0e209f0de 100644 --- a/protocol/goai/goai_path.go +++ b/protocol/goai/goai_path.go @@ -97,9 +97,9 @@ func (oai *OpenApiV3) addPath(in addPathInput) error { in.Path = gmeta.Get(inputObject.Interface(), TagNamePath).String() } if in.Path == "" { - return gerror.NewCode( + return gerror.NewCodef( gcode.CodeMissingParameter, - `missing necessary path parameter "%s" for input struct "%s"`, + `missing necessary path parameter "%s" for input struct "%s", missing tag in attribute Meta?`, TagNamePath, inputStructTypeName, ) } @@ -108,10 +108,10 @@ func (oai *OpenApiV3) addPath(in addPathInput) error { in.Method = gmeta.Get(inputObject.Interface(), TagNameMethod).String() } if in.Method == "" { - return gerror.NewCode( + return gerror.NewCodef( gcode.CodeMissingParameter, - `missing necessary method parameter "%s" for input struct "%s"`, - TagNamePath, inputStructTypeName, + `missing necessary method parameter "%s" for input struct "%s", missing tag in attribute Meta?`, + TagNameMethod, inputStructTypeName, ) } @@ -121,10 +121,10 @@ func (oai *OpenApiV3) addPath(in addPathInput) error { if len(inputMetaMap) > 0 { if err := gconv.Struct(inputMetaMap, &path); err != nil { - return gerror.WrapCodef(gcode.CodeInternalError, err, `mapping struct tags to Path failed`) + return gerror.WrapCode(gcode.CodeInternalError, err, `mapping struct tags to Path failed`) } if err := gconv.Struct(inputMetaMap, &operation); err != nil { - return gerror.WrapCodef(gcode.CodeInternalError, err, `mapping struct tags to Operation failed`) + return gerror.WrapCode(gcode.CodeInternalError, err, `mapping struct tags to Operation failed`) } } // Request. @@ -174,7 +174,7 @@ func (oai *OpenApiV3) addPath(in addPathInput) error { ) if len(outputMetaMap) > 0 { if err := gconv.Struct(outputMetaMap, &response); err != nil { - return gerror.WrapCodef(gcode.CodeInternalError, err, `mapping struct tags to Response failed`) + return gerror.WrapCode(gcode.CodeInternalError, err, `mapping struct tags to Response failed`) } } // Supported mime types of response. diff --git a/protocol/goai/goai_shemaref.go b/protocol/goai/goai_shemaref.go index 7b1eb44cb..1a2b1d346 100644 --- a/protocol/goai/goai_shemaref.go +++ b/protocol/goai/goai_shemaref.go @@ -34,7 +34,7 @@ func (oai *OpenApiV3) newSchemaRefWithGolangType(golangType reflect.Type, tagMap ) if len(tagMap) > 0 { if err := gconv.Struct(tagMap, schema); err != nil { - return nil, gerror.WrapCodef(gcode.CodeInternalError, err, `mapping struct tags to Schema failed`) + return nil, gerror.WrapCode(gcode.CodeInternalError, err, `mapping struct tags to Schema failed`) } } schemaRef.Value = schema