Merge pull request '修复Meta字段解析BUG' (#6) from feature/fix_meta_field into master
Reviewed-on: #6
This commit is contained in:
commit
8387ae08e9
@ -404,6 +404,10 @@ func (g *Generate) ParseReadConfigParam(requestCfg *define.UriBaseConfig, baseRe
|
|||||||
//
|
//
|
||||||
// Date : 15:25 2025/2/8
|
// Date : 15:25 2025/2/8
|
||||||
func (g *Generate) AddComponentsSchema(rootSchemaName string, pkgPath string, inputType reflect.Type) string {
|
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(), ".")
|
inputNameArr := strings.Split(inputType.Name(), ".")
|
||||||
inputName := inputNameArr[len(inputNameArr)-1]
|
inputName := inputNameArr[len(inputNameArr)-1]
|
||||||
schemaName := strings.ReplaceAll(pkgPath+"."+inputName, "/", "-")
|
schemaName := strings.ReplaceAll(pkgPath+"."+inputName, "/", "-")
|
||||||
@ -646,6 +650,9 @@ func (g *Generate) parseBaseUriConfig(uriPrefix string, paramType reflect.Type)
|
|||||||
if len(uriPrefix) > 0 {
|
if len(uriPrefix) > 0 {
|
||||||
res.Uri = strings.TrimRight(uriPrefix, "/") + strings.TrimLeft(res.Uri, "/")
|
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.Method = strings.ToUpper(metaField.Tag.Get(define.TagMethod))
|
||||||
res.Description = metaField.Tag.Get(define.TagDesc)
|
res.Description = metaField.Tag.Get(define.TagDesc)
|
||||||
res.TagList = strings.Split(metaField.Tag.Get(define.TagUriTag), ",")
|
res.TagList = strings.Split(metaField.Tag.Get(define.TagUriTag), ",")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user