fix(goctl): Fix getting swagger consume types (#4903)

This commit is contained in:
jaron
2025-06-07 20:46:34 +08:00
committed by GitHub
parent 91c885b5b0
commit 7969e0ca38

View File

@@ -6,6 +6,7 @@ import (
"time" "time"
"github.com/go-openapi/spec" "github.com/go-openapi/spec"
apiSpec "github.com/zeromicro/go-zero/tools/goctl/api/spec" apiSpec "github.com/zeromicro/go-zero/tools/goctl/api/spec"
"github.com/zeromicro/go-zero/tools/goctl/internal/version" "github.com/zeromicro/go-zero/tools/goctl/internal/version"
) )
@@ -172,13 +173,12 @@ func sampleTypeFromGoType(ctx Context, tp apiSpec.Type) string {
} }
} }
func typeContainsTag(_ Context, structType apiSpec.DefineStruct, tag string) bool { func typeContainsTag(ctx Context, structType apiSpec.DefineStruct, tag string) bool {
for _, field := range structType.Members { members := expandMembers(ctx, structType)
tags, _ := apiSpec.Parse(field.Tag) for _, member := range members {
for _, t := range tags.Tags() { tags, _ := apiSpec.Parse(member.Tag)
if t.Key == tag { if _, err := tags.Get(tag); err == nil {
return true return true
}
} }
} }
return false return false