You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2022/08/08 03:53:05 UTC

[incubator-devlake] branch main updated: docs: swagger support for github plugin

This is an automated email from the ASF dual-hosted git repository.

warren pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 2c7ea2df docs: swagger support for github plugin
2c7ea2df is described below

commit 2c7ea2dfad8fed38f47f23c5ccf64bb171c114d2
Author: Nddtfjiang <jz...@qq.com>
AuthorDate: Mon Aug 8 03:34:39 2022 +0000

    docs: swagger support for github plugin
    
    Swagger support for gitlab plugin.
    
    Nddtfjiang <zh...@merico.dev>
---
 plugins/gitlab/api/connection.go | 77 +++++++++++++++++++++++-----------------
 1 file changed, 45 insertions(+), 32 deletions(-)

diff --git a/plugins/gitlab/api/connection.go b/plugins/gitlab/api/connection.go
index 0c4e2f9d..37e17124 100644
--- a/plugins/gitlab/api/connection.go
+++ b/plugins/gitlab/api/connection.go
@@ -29,6 +29,14 @@ import (
 	"github.com/mitchellh/mapstructure"
 )
 
+// @Summary test gitlab connection
+// @Description Test gitlab Connection
+// @Tags plugins/gitlab
+// @Param body body models.TestConnectionRequest true "json body"
+// @Success 200
+// @Failure 400  {string} errcode.Error "Bad Request"
+// @Failure 500  {string} errcode.Error "Internel Error"
+// @Router /plugins/gitlab/test [POST]
 func TestConnection(input *core.ApiResourceInput) (*core.ApiResourceOutput, error) {
 	// decode
 	var err error
@@ -73,14 +81,14 @@ func TestConnection(input *core.ApiResourceInput) (*core.ApiResourceOutput, erro
 	return nil, nil
 }
 
-/*
-POST /plugins/gitlab/connections
-{
-	"name": "gitlab data connection name",
-	"endpoint": "gitlab api endpoint, i.e. https://gitlab.com/api/v4/",
-	"token": "gitlab api access token"
-}
-*/
+// @Summary create gitlab connection
+// @Description Create gitlab connection
+// @Tags plugins/gitlab
+// @Param body body models.GitlabConnection true "json body"
+// @Success 200
+// @Failure 400  {string} errcode.Error "Bad Request"
+// @Failure 500  {string} errcode.Error "Internel Error"
+// @Router /plugins/gitlab/connections [POST]
 func PostConnections(input *core.ApiResourceInput) (*core.ApiResourceOutput, error) {
 	// update from request and save to database
 	connection := &models.GitlabConnection{}
@@ -91,14 +99,14 @@ func PostConnections(input *core.ApiResourceInput) (*core.ApiResourceOutput, err
 	return &core.ApiResourceOutput{Body: connection, Status: http.StatusOK}, nil
 }
 
-/*
-PATCH /plugins/gitlab/connections/:connectionId
-{
-	"name": "gitlab data connection name",
-	"endpoint": "gitlab api endpoint, i.e. https://gitlab.com/api/v4/",
-	"token": "gitlab api access token"
-}
-*/
+// @Summary patch gitlab connection
+// @Description Patch gitlab connection
+// @Tags plugins/gitlab
+// @Param body body models.GitlabConnection true "json body"
+// @Success 200
+// @Failure 400  {string} errcode.Error "Bad Request"
+// @Failure 500  {string} errcode.Error "Internel Error"
+// @Router /plugins/gitlab/connections/{connectionId} [PATCH]
 func PatchConnection(input *core.ApiResourceInput) (*core.ApiResourceOutput, error) {
 	connection := &models.GitlabConnection{}
 	err := connectionHelper.Patch(connection, input)
@@ -108,9 +116,13 @@ func PatchConnection(input *core.ApiResourceInput) (*core.ApiResourceOutput, err
 	return &core.ApiResourceOutput{Body: connection}, nil
 }
 
-/*
-DELETE /plugins/gitlab/connections/:connectionId
-*/
+// @Summary delete a gitlab connection
+// @Description Delete a gitlab connection
+// @Tags plugins/gitlab
+// @Success 200
+// @Failure 400  {string} errcode.Error "Bad Request"
+// @Failure 500  {string} errcode.Error "Internel Error"
+// @Router /plugins/gitlab/connections/{connectionId} [DELETE]
 func DeleteConnection(input *core.ApiResourceInput) (*core.ApiResourceOutput, error) {
 	connection := &models.GitlabConnection{}
 	err := connectionHelper.First(connection, input.Params)
@@ -121,9 +133,13 @@ func DeleteConnection(input *core.ApiResourceInput) (*core.ApiResourceOutput, er
 	return &core.ApiResourceOutput{Body: connection}, err
 }
 
-/*
-GET /plugins/gitlab/connections
-*/
+// @Summary get all gitlab connections
+// @Description Get all gitlab connections
+// @Tags plugins/gitlab
+// @Success 200
+// @Failure 400  {string} errcode.Error "Bad Request"
+// @Failure 500  {string} errcode.Error "Internel Error"
+// @Router /plugins/gitlab/connections [GET]
 func ListConnections(input *core.ApiResourceInput) (*core.ApiResourceOutput, error) {
 	var connections []models.GitlabConnection
 	err := connectionHelper.List(&connections)
@@ -133,16 +149,13 @@ func ListConnections(input *core.ApiResourceInput) (*core.ApiResourceOutput, err
 	return &core.ApiResourceOutput{Body: connections, Status: http.StatusOK}, nil
 }
 
-/*
-GET /plugins/gitlab/connections/:connectionId
-
-
-{
-	"name": "gitlab data connection name",
-	"endpoint": "gitlab api endpoint, i.e. https://gitlab.com/api/v4/",
-	"token": "gitlab api access token"
-}
-*/
+// @Summary get gitlab connection detail
+// @Description Get gitlab connection detail
+// @Tags plugins/gitlab
+// @Success 200
+// @Failure 400  {string} errcode.Error "Bad Request"
+// @Failure 500  {string} errcode.Error "Internel Error"
+// @Router /plugins/gitlab/connections/{connectionId} [GET]
 func GetConnection(input *core.ApiResourceInput) (*core.ApiResourceOutput, error) {
 	connection := &models.GitlabConnection{}
 	err := connectionHelper.First(connection, input.Params)