Skip to content

Commit

Permalink
feat: define api and generate swagger file
Browse files Browse the repository at this point in the history
Signed-off-by: richardli1598 <opennaslab@gmail.com>
  • Loading branch information
richardli1598 committed Oct 14, 2023
1 parent 05f2310 commit 9874067
Show file tree
Hide file tree
Showing 14 changed files with 519 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bifrost-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
args: --timeout=30m

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
Expand Down
133 changes: 133 additions & 0 deletions api/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 107 additions & 0 deletions api/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"swagger": "2.0",
"info": {
"description": "Take you to the land of light, the city of freedom(A unified external service management system for NAS).",
"title": "bifrost API",
"termsOfService": "http://swagger.io/terms/",
"contact": {},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "0.1"
},
"basePath": "/api/v1",
"paths": {
"/steps": {
"get": {
"description": "List all supported bifrost steps",
"produces": [
"application/json"
],
"tags": [
"Steps"
],
"summary": "List all bifrost steps",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/opennaslab_io_bifrost_pkg_customapi.StepInfoList"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
}
},
"definitions": {
"opennaslab_io_bifrost_pkg_customapi.Documentation": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/opennaslab_io_bifrost_pkg_customapi.Documentation"
}
},
"name": {
"type": "string"
},
"required": {
"type": "boolean"
},
"type": {
"type": "string"
}
}
},
"opennaslab_io_bifrost_pkg_customapi.StepInfo": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"image": {
"type": "string"
},
"name": {
"type": "string"
},
"parameters": {
"$ref": "#/definitions/opennaslab_io_bifrost_pkg_customapi.StepParameter"
}
}
},
"opennaslab_io_bifrost_pkg_customapi.StepInfoList": {
"type": "object",
"properties": {
"steps": {
"type": "array",
"items": {
"$ref": "#/definitions/opennaslab_io_bifrost_pkg_customapi.StepInfo"
}
}
}
},
"opennaslab_io_bifrost_pkg_customapi.StepParameter": {
"type": "object",
"properties": {
"in": {
"type": "array",
"items": {
"$ref": "#/definitions/opennaslab_io_bifrost_pkg_customapi.Documentation"
}
}
}
}
}
}
71 changes: 71 additions & 0 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
basePath: /api/v1
definitions:
opennaslab_io_bifrost_pkg_customapi.Documentation:
properties:
description:
type: string
items:
items:
$ref: '#/definitions/opennaslab_io_bifrost_pkg_customapi.Documentation'
type: array
name:
type: string
required:
type: boolean
type:
type: string
type: object
opennaslab_io_bifrost_pkg_customapi.StepInfo:
properties:
description:
type: string
image:
type: string
name:
type: string
parameters:
$ref: '#/definitions/opennaslab_io_bifrost_pkg_customapi.StepParameter'
type: object
opennaslab_io_bifrost_pkg_customapi.StepInfoList:
properties:
steps:
items:
$ref: '#/definitions/opennaslab_io_bifrost_pkg_customapi.StepInfo'
type: array
type: object
opennaslab_io_bifrost_pkg_customapi.StepParameter:
properties:
in:
items:
$ref: '#/definitions/opennaslab_io_bifrost_pkg_customapi.Documentation'
type: array
type: object
info:
contact: {}
description: Take you to the land of light, the city of freedom(A unified external
service management system for NAS).
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
termsOfService: http://swagger.io/terms/
title: bifrost API
version: "0.1"
paths:
/steps:
get:
description: List all supported bifrost steps
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/opennaslab_io_bifrost_pkg_customapi.StepInfoList'
"500":
description: Internal Server Error
schema:
type: string
summary: List all bifrost steps
tags:
- Steps
swagger: "2.0"
9 changes: 9 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ import (
"opennaslab.io/bifrost/pkg/server"
)

// @title bifrost API
// @version 0.1
// @description Take you to the land of light, the city of freedom(A unified external service management system for NAS).
// @termsOfService http://swagger.io/terms/

// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html

// @BasePath /api/v1
func main() {
opt := options.NewBifrostDBOptions()
if err := opt.Validate(); err != nil {
Expand Down
13 changes: 13 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,30 @@ require (
github.com/docker/docker v24.0.6+incompatible
github.com/gin-contrib/cors v1.4.0
github.com/gin-gonic/gin v1.9.1
github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.0
github.com/swaggo/swag v1.16.2
gorm.io/driver/mysql v1.5.1
gorm.io/gorm v1.25.4
k8s.io/klog v1.0.0
)

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
Expand All @@ -29,10 +39,12 @@ require (
github.com/google/go-cmp v0.5.9 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand All @@ -54,6 +66,7 @@ require (
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
)
Loading

0 comments on commit 9874067

Please sign in to comment.