Fix the issue of generating swagger @doc "xxx" that fails, and use th… (#4816)

Co-authored-by: lxr <qiyuechuqi@an-idear.com>
This commit is contained in:
Rankgice
2025-05-02 15:06:03 +08:00
committed by GitHub
parent 7ef13116a0
commit 52078a0c14
2 changed files with 14 additions and 1 deletions

View File

@@ -69,3 +69,16 @@ func getListFromInfoOrDefault(properties map[string]string, key string, def []st
}
return resp
}
func getFirstUsableString(def ...string) string {
if len(def) == 0 {
return ""
}
for _, val := range def {
str := util.Unquote(val)
if len(str) != 0 {
return str
}
}
return ""
}

View File

@@ -77,7 +77,7 @@ func spec2Path(info apiSpec.Info, group apiSpec.Group, route apiSpec.Route) spec
Produces: getListFromInfoOrDefault(route.AtDoc.Properties, "produces", []string{applicationJson}),
Schemes: getListFromInfoOrDefault(route.AtDoc.Properties, "schemes", []string{schemeHttps}),
Tags: getListFromInfoOrDefault(group.Annotation.Properties, "tags", []string{""}),
Summary: getStringFromKVOrDefault(route.AtDoc.Properties, "summary", ""),
Summary: getStringFromKVOrDefault(route.AtDoc.Properties, "summary", getFirstUsableString(route.AtDoc.Text, route.Handler)),
Deprecated: getBoolFromKVOrDefault(route.AtDoc.Properties, "deprecated", false),
Parameters: parametersFromType(route.Method, route.RequestType),
Responses: jsonResponseFromType(info, route.ResponseType),