mirror of
https://github.com/datarhei/core.git
synced 2025-10-06 16:37:04 +08:00
Add v16.8.0
This commit is contained in:
18
vendor/github.com/swaggo/swag/spec.go
generated
vendored
18
vendor/github.com/swaggo/swag/spec.go
generated
vendored
@@ -21,31 +21,33 @@ type Spec struct {
|
||||
|
||||
// ReadDoc parses SwaggerTemplate into swagger document.
|
||||
func (i *Spec) ReadDoc() string {
|
||||
i.Description = strings.Replace(i.Description, "\n", "\\n", -1)
|
||||
i.Description = strings.ReplaceAll(i.Description, "\n", "\\n")
|
||||
|
||||
t, err := template.New("swagger_info").Funcs(template.FuncMap{
|
||||
tpl, err := template.New("swagger_info").Funcs(template.FuncMap{
|
||||
"marshal": func(v interface{}) string {
|
||||
a, _ := json.Marshal(v)
|
||||
|
||||
return string(a)
|
||||
},
|
||||
"escape": func(v interface{}) string {
|
||||
// escape tabs
|
||||
str := strings.Replace(v.(string), "\t", "\\t", -1)
|
||||
var str = strings.ReplaceAll(v.(string), "\t", "\\t")
|
||||
// replace " with \", and if that results in \\", replace that with \\\"
|
||||
str = strings.Replace(str, "\"", "\\\"", -1)
|
||||
return strings.Replace(str, "\\\\\"", "\\\\\\\"", -1)
|
||||
str = strings.ReplaceAll(str, "\"", "\\\"")
|
||||
|
||||
return strings.ReplaceAll(str, "\\\\\"", "\\\\\\\"")
|
||||
},
|
||||
}).Parse(i.SwaggerTemplate)
|
||||
if err != nil {
|
||||
return i.SwaggerTemplate
|
||||
}
|
||||
|
||||
var tpl bytes.Buffer
|
||||
if err = t.Execute(&tpl, i); err != nil {
|
||||
var doc bytes.Buffer
|
||||
if err = tpl.Execute(&doc, i); err != nil {
|
||||
return i.SwaggerTemplate
|
||||
}
|
||||
|
||||
return tpl.String()
|
||||
return doc.String()
|
||||
}
|
||||
|
||||
// InstanceName returns Spec instance name.
|
||||
|
Reference in New Issue
Block a user