feat: base: upgrade swagger

This commit is contained in:
fallen-angle
2022-02-15 17:41:07 +08:00
parent be5def58fd
commit 4f3b16ab9d
6 changed files with 75 additions and 70 deletions

View File

@@ -2,16 +2,9 @@
// This file was generated by swaggo/swag
package docs
import (
"bytes"
"encoding/json"
"strings"
"text/template"
import "github.com/swaggo/swag"
"github.com/swaggo/swag"
)
var doc = `{
const docTemplate_swagger = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
@@ -25,6 +18,9 @@ var doc = `{
"paths": {
"/statistics/china": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Statistics"
],
@@ -53,6 +49,9 @@ var doc = `{
},
"/statistics/city/{sort}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Statistics"
],
@@ -98,6 +97,9 @@ var doc = `{
},
"/statistics/country": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Statistics"
],
@@ -129,6 +131,9 @@ var doc = `{
},
"/statistics/country/child": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Statistics"
],
@@ -158,12 +163,15 @@ var doc = `{
}
}
},
"/statistics/provience/{sort}": {
"/statistics/province/{sort}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Statistics"
],
"summary": "provience statistics",
"summary": "province statistics",
"parameters": [
{
"enum": [
@@ -374,56 +382,18 @@ var doc = `{
}
}`
type swaggerInfo struct {
Version string
Host string
BasePath string
Schemes []string
Title string
Description string
}
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = swaggerInfo{
Version: "1.0",
Host: "",
BasePath: "",
Schemes: []string{},
Title: "nCov Tracker",
Description: "",
}
type s struct{}
func (s *s) ReadDoc() string {
sInfo := SwaggerInfo
sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1)
t, 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)
// replace " with \", and if that results in \\", replace that with \\\"
str = strings.Replace(str, "\"", "\\\"", -1)
return strings.Replace(str, "\\\\\"", "\\\\\\\"", -1)
},
}).Parse(doc)
if err != nil {
return doc
}
var tpl bytes.Buffer
if err := t.Execute(&tpl, sInfo); err != nil {
return doc
}
return tpl.String()
// SwaggerInfo_swagger holds exported Swagger Info so clients can modify it
var SwaggerInfo_swagger = &swag.Spec{
Version: "1.0",
Host: "",
BasePath: "",
Schemes: []string{},
Title: "nCov Tracker",
Description: "",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate_swagger,
}
func init() {
swag.Register("swagger", &s{})
swag.Register(SwaggerInfo_swagger.InstanceName(), SwaggerInfo_swagger)
}