Skip to content
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,7 @@ vendor
bin
libgit2
.air.toml

#swagger .json and .yaml
api/docs/swagger.json
api/docs/swagger.yaml
12 changes: 12 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,28 @@ package api
import (
"time"

_ "github.com/merico-dev/lake/api/docs"

"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/merico-dev/lake/config"
ginSwagger "github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
)

// @title DevLake Swagger API
// @version 0.1
// @description <h2>This is the main page of devlake api</h2>
// sdfasdfasd
// @license.name Apache-2.0
// @host localhost:8080
// @BasePath /
func CreateApiService() {
v := config.GetConfig()
gin.SetMode(v.GetString("MODE"))
router := gin.Default()

router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
// CORS CONFIG
router.Use(cors.New(cors.Config{
AllowOrigins: []string{"*"},
Expand Down
43 changes: 43 additions & 0 deletions api/blueprints/blueprints.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ import (
"github.com/merico-dev/lake/services"
)

// @Summary post blueprints
// @Description post blueprints
// @Tags Blueprints
// @Accept application/json
// @Param blueprint body string true "json"
// @Success 200 {object} models.Blueprint
// @Failure 400 {string} errcode.Error "Bad Request"
// @Failure 500 {string} errcode.Error "Internel Error"
// @Router /blueprints [post]
func Post(c *gin.Context) {
blueprint := &models.Blueprint{}

Expand All @@ -29,6 +38,14 @@ func Post(c *gin.Context) {
shared.ApiOutputSuccess(c, blueprint, http.StatusCreated)
}

// @Summary get blueprints
// @Description get blueprints
// @Tags Blueprints
// @Accept application/json
// @Success 200 {object} gin.H
// @Failure 400 {string} errcode.Error "Bad Request"
// @Failure 500 {string} errcode.Error "Internel Error"
// @Router /blueprints [get]
func Index(c *gin.Context) {
var query services.BlueprintQuery
err := c.ShouldBindQuery(&query)
Expand All @@ -44,6 +61,15 @@ func Index(c *gin.Context) {
shared.ApiOutputSuccess(c, gin.H{"blueprints": blueprints, "count": count}, http.StatusOK)
}

// @Summary get blueprints
// @Description get blueprints
// @Tags Blueprints
// @Accept application/json
// @Param blueprintId path int true "blueprint id"
// @Success 200 {object} models.Blueprint
// @Failure 400 {string} errcode.Error "Bad Request"
// @Failure 500 {string} errcode.Error "Internel Error"
// @Router /blueprints/{blueprintId} [get]
func Get(c *gin.Context) {
blueprintId := c.Param("blueprintId")
id, err := strconv.ParseUint(blueprintId, 10, 64)
Expand All @@ -59,6 +85,14 @@ func Get(c *gin.Context) {
shared.ApiOutputSuccess(c, blueprint, http.StatusOK)
}

// @Summary delete blueprints
// @Description Delete BluePrints
// @Tags Blueprints
// @Param blueprintId path string true "blueprintId"
// @Success 200
// @Failure 400 {string} errcode.Error "Bad Request"
// @Failure 500 {string} errcode.Error "Internel Error"
// @Router /blueprints/{blueprintId} [delete]
func Delete(c *gin.Context) {
pipelineId := c.Param("blueprintId")
id, err := strconv.ParseUint(pipelineId, 10, 64)
Expand Down Expand Up @@ -97,6 +131,15 @@ func Put(c *gin.Context) {
}
*/

// @Summary patch blueprints
// @Description patch blueprints
// @Tags Blueprints
// @Accept application/json
// @Param blueprintId path string true "blueprintId"
// @Success 200 {object} models.Blueprint
// @Failure 400 {string} errcode.Error "Bad Request"
// @Failure 500 {string} errcode.Error "Internel Error"
// @Router /blueprints/{blueprintId} [Patch]
func Patch(c *gin.Context) {
blueprintId := c.Param("blueprintId")
id, err := strconv.ParseUint(blueprintId, 10, 64)
Expand Down
Loading