Add swagger docs

This commit is contained in:
hantmac
2020-05-01 23:11:51 +08:00
parent 09ea0bb56a
commit f59ca2b605
11 changed files with 7977 additions and 0 deletions

View File

@@ -8,6 +8,14 @@ import (
"net/http"
)
// @Summary Get nodes
// @Description Get nodes
// @Tags node
// @Produce json
// @Param Authorization header string true "With the bearer started"
// @Success 200 json string Response
// @Failure 400 json string Response
// @Router /nodes [get]
func GetNodeList(c *gin.Context) {
nodes, err := model.GetNodeList(nil)
if err != nil {
@@ -26,6 +34,15 @@ func GetNodeList(c *gin.Context) {
})
}
// @Summary Get node
// @Description Get node
// @Tags node
// @Produce json
// @Param Authorization header string true "With the bearer started"
// @Param id path string true "id"
// @Success 200 json string Response
// @Failure 400 json string Response
// @Router /nodes/{id} [get]
func GetNode(c *gin.Context) {
id := c.Param("id")
@@ -54,6 +71,17 @@ func Ping(c *gin.Context) {
})
}
// @Summary Post node
// @Description Post node
// @Tags node
// @Accept json
// @Produce json
// @Param Authorization header string true "With the bearer started"
// @Param id path string true "post node"
// @Success 200 json string Response
// @Failure 500 json string Response
// @Router /nodes/{id} [post]
func PostNode(c *gin.Context) {
id := c.Param("id")
@@ -81,6 +109,15 @@ func PostNode(c *gin.Context) {
})
}
// @Summary Get tasks on node
// @Description Get tasks on node
// @Tags node
// @Produce json
// @Param Authorization header string true "With the bearer started"
// @Param id path string true "node id"
// @Success 200 json string Response
// @Failure 400 json string Response
// @Router /nodes/{id}/tasks [get]
func GetNodeTaskList(c *gin.Context) {
id := c.Param("id")
@@ -97,6 +134,15 @@ func GetNodeTaskList(c *gin.Context) {
})
}
// @Summary Get system info
// @Description Get system info
// @Tags node
// @Produce json
// @Param Authorization header string true "With the bearer started"
// @Param id path string true "node id"
// @Success 200 json string Response
// @Failure 400 json string Response
// @Router /nodes/{id}/system [get]
func GetSystemInfo(c *gin.Context) {
id := c.Param("id")
@@ -109,6 +155,15 @@ func GetSystemInfo(c *gin.Context) {
})
}
// @Summary Delete node
// @Description Delete node
// @Tags node
// @Produce json
// @Param Authorization header string true "With the bearer started"
// @Param id path string true "node id"
// @Success 200 json string Response
// @Failure 400 json string Response
// @Router /nodes/{id} [delete]
func DeleteNode(c *gin.Context) {
id := c.Param("id")
node, err := model.GetNode(bson.ObjectIdHex(id))