Skip to content

Commit

Permalink
Merge pull request #1072 from cloud-barista/update-swagger-doc
Browse files Browse the repository at this point in the history
[Workflow] Update Swagger REST API doc
  • Loading branch information
seokho-son authored Apr 28, 2022
2 parents 3809976 + 6efec87 commit 2d9845d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 62 deletions.
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

0 comments on commit 2d9845d

Please sign in to comment.