Skip to content

Commit

Permalink
Add swagger API documentation for VPC, SG and KeyPair Management APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
powerkimhub committed Aug 27, 2024
1 parent c02c472 commit 90d3045
Show file tree
Hide file tree
Showing 15 changed files with 817 additions and 1,224 deletions.
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
default: cli
default: swag cli
@echo -e '\t[CB-Spider] build ./bin/cb-spider....'
@go mod download
@go mod tidy
@go build -o bin/cb-spider ./api-runtime
dyna plugin plug dynamic: cli
dyna plugin plug dynamic: swag cli
@echo -e '\t[CB-Spider] build ./bin/cb-spider with plugin mode...'
@go mod download
@go build -tags dyna -o bin/cb-spider-dyna ./api-runtime
@./build_all_driver_lib.sh;
cc:
cc: swag
@echo -e '\t[CB-Spider] build ./bin/cb-spider-arm for arm...'
GOOS=linux GOARCH=arm go build -o cb-spider-arm ./api-runtime
clean clear:
Expand Down Expand Up @@ -36,5 +36,11 @@ cli:

swag swagger:
@echo -e '\t[CB-Spider] build Swagger docs'
@~/go/bin/swag i -g api-runtime/rest-runtime/CBSpiderRuntime.go -o api-runtime/rest-runtime/docs
@~/go/bin/swag i -g api-runtime/rest-runtime/CBSpiderRuntime.go -d ./,./cloud-control-manager -o api
@sed -i 's/github_com_cloud-barista_cb-spider_cloud-control-manager_cloud-driver_interfaces_resources./spider./g' ./api/docs.go
@sed -i 's/github_com_cloud-barista_cb-spider_cloud-control-manager_cloud-driver_interfaces_resources./spider./g' ./api/swagger.json
@sed -i 's/github_com_cloud-barista_cb-spider_cloud-control-manager_cloud-driver_interfaces_resources./spider./g' ./api/swagger.yaml
@sed -i 's/restruntime./spider./g' ./api/docs.go
@sed -i 's/restruntime./spider./g' ./api/swagger.json
@sed -i 's/restruntime./spider./g' ./api/swagger.yaml

14 changes: 11 additions & 3 deletions api-runtime/rest-runtime/CBSpiderRuntime.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/labstack/echo/v4/middleware"

// echo-swagger middleware
_ "github.com/cloud-barista/cb-spider/api-runtime/rest-runtime/docs"
_ "github.com/cloud-barista/cb-spider/api"
echoSwagger "github.com/swaggo/echo-swagger"

"github.com/natefinch/lumberjack"
Expand All @@ -52,8 +52,11 @@ var cblog *logrus.Logger
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html

// @host localhost:1024

// @BasePath /spider

// @schemes http

// @securityDefinitions.basic BasicAuth

func init() {
Expand Down Expand Up @@ -89,7 +92,7 @@ type route struct {

// JSON Simple message struct
type SimpleMsg struct {
Message string `json:"message" example:"Any message"`
Message string `json:"message" validate:"required" example:"Any message" description:"A simple message to be returned by the API"`
}

//// CB-Spider Servcie Address Configuration
Expand Down Expand Up @@ -185,7 +188,9 @@ func RunServer() {
{"GET", "/", aw.SpiderInfo},

//----------Swagger
{"GET", "/swagger/*", echoSwagger.WrapHandler},
{"GET", "/api", echoSwagger.WrapHandler},
{"GET", "/api/", echoSwagger.WrapHandler},
{"GET", "/api/*", echoSwagger.WrapHandler},

//----------EndpointInfo
{"GET", "/endpointinfo", endpointInfo},
Expand Down Expand Up @@ -598,6 +603,9 @@ func ApiServer(routes []route) {
// for WebTerminal
e.Static("/spider/adminweb/static", filepath.Join(cbspiderRoot, "api-runtime/rest-runtime/admin-web/static"))

// for swagger
e.Static("/spider/swagger", filepath.Join(cbspiderRoot, "api"))

e.HideBanner = true
e.HidePort = true

Expand Down
Loading

0 comments on commit 90d3045

Please sign in to comment.