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 #1072

Merged
merged 1 commit into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 17 additions & 60 deletions src/api/rest/docs/docs.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// Package docs GENERATED BY SWAG; DO NOT EDIT
// 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 = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
Expand Down Expand Up @@ -6729,7 +6722,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 @@ -6839,7 +6833,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 @@ -7194,56 +7189,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: "",
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()
var SwaggerInfo = &swag.Spec{
Version: "latest",
Host: "",
BasePath: "/tumblebug",
Schemes: []string{},
Title: "CB-Tumblebug REST API",
Description: "CB-Tumblebug REST API",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
}

func init() {
swag.Register(swag.Name, &s{})
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
6 changes: 4 additions & 2 deletions src/api/rest/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -6714,7 +6714,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 @@ -6824,7 +6825,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
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,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 @@ -1411,6 +1412,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