Merge pull request '修复Meta字段解析BUG' (#6) from feature/fix_meta_field into master

Reviewed-on: #6
This commit is contained in:
白茶清欢 2025-02-15 20:01:52 +08:00
commit 8387ae08e9

View File

@ -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), ",")