mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-14 02:10:00 +08:00
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:
@@ -69,3 +69,16 @@ func getListFromInfoOrDefault(properties map[string]string, key string, def []st
|
|||||||
}
|
}
|
||||||
return resp
|
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 ""
|
||||||
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ func spec2Path(info apiSpec.Info, group apiSpec.Group, route apiSpec.Route) spec
|
|||||||
Produces: getListFromInfoOrDefault(route.AtDoc.Properties, "produces", []string{applicationJson}),
|
Produces: getListFromInfoOrDefault(route.AtDoc.Properties, "produces", []string{applicationJson}),
|
||||||
Schemes: getListFromInfoOrDefault(route.AtDoc.Properties, "schemes", []string{schemeHttps}),
|
Schemes: getListFromInfoOrDefault(route.AtDoc.Properties, "schemes", []string{schemeHttps}),
|
||||||
Tags: getListFromInfoOrDefault(group.Annotation.Properties, "tags", []string{""}),
|
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),
|
Deprecated: getBoolFromKVOrDefault(route.AtDoc.Properties, "deprecated", false),
|
||||||
Parameters: parametersFromType(route.Method, route.RequestType),
|
Parameters: parametersFromType(route.Method, route.RequestType),
|
||||||
Responses: jsonResponseFromType(info, route.ResponseType),
|
Responses: jsonResponseFromType(info, route.ResponseType),
|
||||||
|
|||||||
Reference in New Issue
Block a user