From cb7821bbcf6675772e6212346bff31dc0c479408 Mon Sep 17 00:00:00 2001 From: seokho-son Date: Wed, 9 Feb 2022 01:23:10 +0000 Subject: [PATCH] Update Swagger REST API doc --- src/api/rest/docs/docs.go | 77 ++++++++-------------------------- src/api/rest/docs/swagger.json | 6 ++- src/api/rest/docs/swagger.yaml | 2 + 3 files changed, 23 insertions(+), 62 deletions(-) diff --git a/src/api/rest/docs/docs.go b/src/api/rest/docs/docs.go index 3d627f66..a934c40b 100644 --- a/src/api/rest/docs/docs.go +++ b/src/api/rest/docs/docs.go @@ -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": { @@ -6501,7 +6494,8 @@ var doc = `{ }, "systemLabel": { "description": "SystemLabel is for describing the mcis in a keyword (any string can be used) for special System purpose", - "type": "string" + "type": "string", + "example": "" }, "vm": { "type": "array", @@ -6601,7 +6595,8 @@ var doc = `{ }, "systemLabel": { "description": "SystemLabel is for describing the mcis in a keyword (any string can be used) for special System purpose", - "type": "string" + "type": "string", + "example": "" }, "vm": { "type": "array", @@ -6913,56 +6908,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: "latest", - Host: "localhost:1323", - BasePath: "/tumblebug", - Schemes: []string{}, - Title: "CB-Tumblebug REST API", - Description: "CB-Tumblebug REST API", -} - -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: "latest", + Host: "localhost:1323", + BasePath: "/tumblebug", + Schemes: []string{}, + Title: "CB-Tumblebug REST API", + Description: "CB-Tumblebug REST API", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate_swagger, } func init() { - swag.Register("swagger", &s{}) + swag.Register(SwaggerInfo_swagger.InstanceName(), SwaggerInfo_swagger) } diff --git a/src/api/rest/docs/swagger.json b/src/api/rest/docs/swagger.json index ba430731..1218d2a0 100644 --- a/src/api/rest/docs/swagger.json +++ b/src/api/rest/docs/swagger.json @@ -6487,7 +6487,8 @@ }, "systemLabel": { "description": "SystemLabel is for describing the mcis in a keyword (any string can be used) for special System purpose", - "type": "string" + "type": "string", + "example": "" }, "vm": { "type": "array", @@ -6587,7 +6588,8 @@ }, "systemLabel": { "description": "SystemLabel is for describing the mcis in a keyword (any string can be used) for special System purpose", - "type": "string" + "type": "string", + "example": "" }, "vm": { "type": "array", diff --git a/src/api/rest/docs/swagger.yaml b/src/api/rest/docs/swagger.yaml index f09d7676..3d764026 100644 --- a/src/api/rest/docs/swagger.yaml +++ b/src/api/rest/docs/swagger.yaml @@ -1252,6 +1252,7 @@ definitions: systemLabel: description: SystemLabel is for describing the mcis in a keyword (any string can be used) for special System purpose + example: "" type: string vm: items: @@ -1330,6 +1331,7 @@ definitions: systemLabel: description: SystemLabel is for describing the mcis in a keyword (any string can be used) for special System purpose + example: "" type: string vm: items: