mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
openapi
This commit is contained in:
@ -99,6 +99,7 @@ func New() *OpenApiV3 {
|
||||
// AddInput is the structured parameter for function OpenApiV3.Add.
|
||||
type AddInput struct {
|
||||
Path string // Path specifies the custom path if this is not configured in Meta of struct tag.
|
||||
Prefix string // Prefix specifies the custom route path prefix, which will be added with the path tag in Meta of struct tag.
|
||||
Method string // Method specifies the custom HTTP method if this is not configured in Meta of struct tag.
|
||||
Object interface{} // Object can be an instance of struct or a route function.
|
||||
}
|
||||
|
||||
@ -41,9 +41,10 @@ const (
|
||||
)
|
||||
|
||||
type addPathInput struct {
|
||||
Path string
|
||||
Method string
|
||||
Function interface{}
|
||||
Path string // Precise route path.
|
||||
Prefix string // Route path prefix.
|
||||
Method string // Route method.
|
||||
Function interface{} // Uniformed function.
|
||||
}
|
||||
|
||||
func (oai *OpenApiV3) addPath(in addPathInput) error {
|
||||
@ -97,6 +98,9 @@ func (oai *OpenApiV3) addPath(in addPathInput) error {
|
||||
// Path check.
|
||||
if in.Path == "" {
|
||||
in.Path = gmeta.Get(inputObject.Interface(), TagNamePath).String()
|
||||
if in.Prefix != "" {
|
||||
in.Path = gstr.TrimRight(in.Prefix, "/") + "/" + gstr.TrimLeft(in.Path, "/")
|
||||
}
|
||||
}
|
||||
if in.Path == "" {
|
||||
return gerror.NewCodef(
|
||||
@ -105,6 +109,7 @@ func (oai *OpenApiV3) addPath(in addPathInput) error {
|
||||
TagNamePath, inputStructTypeName,
|
||||
)
|
||||
}
|
||||
|
||||
// Method check.
|
||||
if in.Method == "" {
|
||||
in.Method = gmeta.Get(inputObject.Interface(), TagNameMethod).String()
|
||||
|
||||
Reference in New Issue
Block a user