diff --git a/generate.go b/generate.go index 405cc62..c05be3f 100644 --- a/generate.go +++ b/generate.go @@ -404,6 +404,10 @@ func (g *Generate) ParseReadConfigParam(requestCfg *define.UriBaseConfig, baseRe // // Date : 15:25 2025/2/8 func (g *Generate) AddComponentsSchema(rootSchemaName string, pkgPath string, inputType reflect.Type) string { + if inputType.Kind() == reflect.Struct && inputType.String() == "Meta" && inputType.NumField() == 0 { + // 空Meta字段认为是用来描述元信息的, 忽略 + return "-" + } inputNameArr := strings.Split(inputType.Name(), ".") inputName := inputNameArr[len(inputNameArr)-1] schemaName := strings.ReplaceAll(pkgPath+"."+inputName, "/", "-") @@ -646,6 +650,9 @@ func (g *Generate) parseBaseUriConfig(uriPrefix string, paramType reflect.Type) if len(uriPrefix) > 0 { res.Uri = strings.TrimRight(uriPrefix, "/") + strings.TrimLeft(res.Uri, "/") } + // 保证接口路由以 /开头 + res.Uri = "/" + strings.TrimLeft(res.Uri, "/") + res.Method = strings.ToUpper(metaField.Tag.Get(define.TagMethod)) res.Description = metaField.Tag.Get(define.TagDesc) res.TagList = strings.Split(metaField.Tag.Get(define.TagUriTag), ",")