Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Workflow] Update Swagger REST API doc #1027

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
77 changes: 17 additions & 60 deletions src/api/rest/docs/docs.go
Expand Up @@ -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": {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
}
6 changes: 4 additions & 2 deletions src/api/rest/docs/swagger.json
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/api/rest/docs/swagger.yaml
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down