update swagger descriptions

This commit is contained in:
2023-04-24 16:53:10 +02:00
parent be4545e603
commit 8ee64aa49f
11 changed files with 916 additions and 230 deletions

View File

@@ -1,6 +1,7 @@
package controllers
import (
"net/http"
"os"
"forge.redroom.link/yves/sqldb"
@@ -13,17 +14,18 @@ type SchemaController struct {
beego.Controller
}
// @Title GetTable
// @Description get list table
// @Title GetTablesList
// @Description Get database tables list
// @Success 200 {string} success !
// @Failure 403 no table
// @Failure 500 query error
// @router / [get]
func (s *SchemaController) GetTable() {
func (s *SchemaController) GetTablesList() {
db := sqldb.Open(os.Getenv("driverdb"), os.Getenv("paramsdb"))
data, err := db.ListTables()
if err != nil {
log.Error().Msg(err.Error())
s.Data["json"] = map[string]string{"error": err.Error()}
s.Ctx.Output.SetStatus(http.StatusInternalServerError)
}
s.Data["json"] = data
s.ServeJSON()
@@ -32,10 +34,10 @@ func (s *SchemaController) GetTable() {
}
// @Title GetSchema
// @Description get table schema
// @Description Get table schema
// @Param table path string true "Name of the table"
// @Success 200 success !
// @Failure 403 no table
// @Failure 204 no table
// @router /:table [get]
func (s *SchemaController) GetSchema() {
table := s.GetString(":table")
@@ -44,6 +46,7 @@ func (s *SchemaController) GetSchema() {
if err != nil {
log.Error().Msg(err.Error())
s.Data["json"] = map[string]string{"error": err.Error()}
s.Ctx.Output.SetStatus(http.StatusNoContent)
}
s.Data["json"] = data
s.ServeJSON()