From 55ecf3c8eaa5afca1af0eb0ead854fd9e9eaa973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sat, 15 Feb 2025 20:01:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DMeta=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=A7=A3=E6=9E=90BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generate.go | 7 +++++++ 1 file changed, 7 insertions(+) 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), ",")