update swagger descriptions
This commit is contained in:
parent
be4545e603
commit
8ee64aa49f
BIN
.README.md.swp
Normal file
BIN
.README.md.swp
Normal file
Binary file not shown.
7
.vscode/launch.json
vendored
Normal file
7
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": []
|
||||
}
|
@ -6,6 +6,10 @@ Some special tables can be used for defining database access restrictions based
|
||||
> export GOPRIVATE=forge.redroom.link
|
||||
before doing go mod tidy.
|
||||
|
||||
Installing bee command
|
||||
----------------------
|
||||
> go get github.com/beego/bee/v2
|
||||
|
||||
Running in debug mode
|
||||
---------------------
|
||||
> bee run -downdoc=true -gendoc=true
|
||||
|
@ -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()
|
||||
|
@ -185,7 +185,7 @@ func (t *TableController) GetAllTableColumnRestriction() {
|
||||
// @Param table path string true "Name of the table"
|
||||
// @Param columns path string true "Name of the columns (separate with a comma)"
|
||||
// @Param restriction path string true "SQL restriction"
|
||||
// @param sortkeys path string true "column name"
|
||||
// @Param sortkeys path string true "Order by: columns names (separate with a comma)"
|
||||
// @Success 200 {string} success !
|
||||
// @Failure 403 no table
|
||||
// @router /:table/:columns/:restriction/:sortkeys [get]
|
||||
@ -210,8 +210,8 @@ func (t *TableController) GetAllTableColumnRestrictionSortkeys() {
|
||||
// @Param table path string true "Name of the table"
|
||||
// @Param columns path string true "Name of the columns (separate with a comma)"
|
||||
// @Param restriction path string true "SQL restriction"
|
||||
// @param sortkeys path string true "column name"
|
||||
// @param dir path string true "asc or desc"
|
||||
// @Param sortkeys path string true "Order by: columns names (separate with a comma)"
|
||||
// @Param dir path string true "asc or desc"
|
||||
// @Success 200 {string} success !
|
||||
// @Failure 403 no table
|
||||
// @router /:table/:columns/:restriction/:sortkeys/:dir [get]
|
||||
|
54
go.mod
54
go.mod
@ -2,24 +2,46 @@ module sqldb-ws
|
||||
|
||||
go 1.16
|
||||
|
||||
require github.com/beego/beego/v2 v2.0.2
|
||||
require github.com/beego/beego/v2 v2.0.7
|
||||
|
||||
require (
|
||||
forge.redroom.link/yves/sqldb v0.0.0-20220520131204-4e17758e157e
|
||||
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
||||
github.com/lib/pq v1.10.6
|
||||
github.com/matthewhartstonge/argon2 v0.2.1
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
forge.redroom.link/yves/sqldb v0.0.0-20230130111657-cf652439b461
|
||||
github.com/apache/thrift v0.13.0 // indirect
|
||||
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a // indirect
|
||||
github.com/aws/aws-lambda-go v1.13.3 // indirect
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec // indirect
|
||||
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
|
||||
github.com/hashicorp/go.net v0.0.1 // indirect
|
||||
github.com/lib/pq v1.10.7
|
||||
github.com/lightstep/lightstep-tracer-go v0.18.1 // indirect
|
||||
github.com/matthewhartstonge/argon2 v0.3.2
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
|
||||
github.com/mitchellh/gox v0.4.0 // indirect
|
||||
github.com/mitchellh/iochan v1.0.0 // indirect
|
||||
github.com/nats-io/jwt v0.3.2 // indirect
|
||||
github.com/oklog/oklog v0.3.2 // indirect
|
||||
github.com/oklog/run v1.0.0 // indirect
|
||||
github.com/opentracing/basictracer-go v1.0.0 // indirect
|
||||
github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5 // indirect
|
||||
github.com/pact-foundation/pact-go v1.0.4 // indirect
|
||||
github.com/pborman/uuid v1.2.0 // indirect
|
||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
|
||||
github.com/prometheus/client_golang v1.12.2 // indirect
|
||||
github.com/prometheus/common v0.34.0 // indirect
|
||||
github.com/rs/zerolog v1.26.1
|
||||
github.com/performancecopilot/speed v3.0.0+incompatible // indirect
|
||||
github.com/prometheus/client_model v0.3.0 // indirect
|
||||
github.com/prometheus/common v0.39.0 // indirect
|
||||
github.com/prometheus/procfs v0.9.0 // indirect
|
||||
github.com/rs/zerolog v1.29.0
|
||||
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da // indirect
|
||||
github.com/smartystreets/goconvey v1.6.4
|
||||
github.com/spf13/cast v1.5.0 // indirect
|
||||
github.com/spf13/viper v1.11.0
|
||||
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 // indirect
|
||||
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect
|
||||
golang.org/x/sys v0.0.0-20220519141025-dcacdad47464 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20220512140231-539c8e751b99 // indirect
|
||||
github.com/spf13/viper v1.15.0
|
||||
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271 // indirect
|
||||
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738 // indirect
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee // indirect
|
||||
golang.org/x/crypto v0.5.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 // indirect
|
||||
)
|
||||
|
@ -36,7 +36,7 @@ func init() {
|
||||
|
||||
beego.GlobalControllerRouter["sqldb-ws/controllers:SchemaController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:SchemaController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetTable",
|
||||
Method: "GetTablesList",
|
||||
Router: "/",
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
func CheckSelect(dbuser_id string, table *string, columns *string, restriction *string) {
|
||||
|
||||
//fmt.Println(dbuser_id, fmt.Sprintf("%v", table), fmt.Sprintf("%v", columns), fmt.Sprintf("%v", restriction))
|
||||
fmt.Println(dbuser_id, fmt.Sprintf("%v", table), fmt.Sprintf("%v", columns), fmt.Sprintf("%v", restriction))
|
||||
}
|
||||
|
||||
func removeLastChar(s string) string {
|
||||
|
@ -2,7 +2,7 @@
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "beego Test API",
|
||||
"description": "beego has a very cool tools to autogenerate documents for your API",
|
||||
"description": "beego has a very cool tools to autogenerate documents for your API\n",
|
||||
"version": "1.0.0",
|
||||
"termsOfService": "http://beego.me/",
|
||||
"contact": {
|
||||
@ -20,7 +20,7 @@
|
||||
"tags": [
|
||||
"l"
|
||||
],
|
||||
"description": "Add user",
|
||||
"description": "Add user\n\u003cbr\u003e",
|
||||
"operationId": "LoginController.AddUser",
|
||||
"parameters": [
|
||||
{
|
||||
@ -53,7 +53,7 @@
|
||||
"tags": [
|
||||
"l"
|
||||
],
|
||||
"description": "User login",
|
||||
"description": "User login\n\u003cbr\u003e",
|
||||
"operationId": "LoginController.Login",
|
||||
"parameters": [
|
||||
{
|
||||
@ -84,7 +84,7 @@
|
||||
"tags": [
|
||||
"l"
|
||||
],
|
||||
"description": "Logs user",
|
||||
"description": "Logs user\n\u003cbr\u003e",
|
||||
"operationId": "LoginController.Logout",
|
||||
"responses": {
|
||||
"200": {
|
||||
@ -101,14 +101,14 @@
|
||||
"tags": [
|
||||
"s"
|
||||
],
|
||||
"description": "get list table",
|
||||
"operationId": "SchemaController.GetTable",
|
||||
"description": "Get database tables list\n\u003cbr\u003e",
|
||||
"operationId": "SchemaController.GetTablesList",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{string} success !"
|
||||
},
|
||||
"403": {
|
||||
"description": "no table"
|
||||
"500": {
|
||||
"description": "query error"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -118,7 +118,7 @@
|
||||
"tags": [
|
||||
"s"
|
||||
],
|
||||
"description": "get table schema",
|
||||
"description": "Get table schema\n\u003cbr\u003e",
|
||||
"operationId": "SchemaController.GetSchema",
|
||||
"parameters": [
|
||||
{
|
||||
@ -133,7 +133,7 @@
|
||||
"200": {
|
||||
"description": "success !"
|
||||
},
|
||||
"403": {
|
||||
"204": {
|
||||
"description": "no table"
|
||||
}
|
||||
}
|
||||
@ -144,7 +144,7 @@
|
||||
"tags": [
|
||||
"t"
|
||||
],
|
||||
"description": "get all Datas",
|
||||
"description": "get all Datas\n\u003cbr\u003e",
|
||||
"operationId": "TableController.GetAllTable",
|
||||
"parameters": [
|
||||
{
|
||||
@ -168,7 +168,7 @@
|
||||
"tags": [
|
||||
"t"
|
||||
],
|
||||
"description": "put data in table",
|
||||
"description": "put data in table\n\u003cbr\u003e",
|
||||
"operationId": "TableController.Put data in table",
|
||||
"parameters": [
|
||||
{
|
||||
@ -201,7 +201,7 @@
|
||||
"tags": [
|
||||
"t"
|
||||
],
|
||||
"description": "get all Datas",
|
||||
"description": "get all Datas\n\u003cbr\u003e",
|
||||
"operationId": "TableController.TablePost",
|
||||
"parameters": [
|
||||
{
|
||||
@ -234,7 +234,7 @@
|
||||
"tags": [
|
||||
"t"
|
||||
],
|
||||
"description": "delete the data in table",
|
||||
"description": "delete the data in table\n\u003cbr\u003e",
|
||||
"operationId": "TableController.Delete",
|
||||
"parameters": [
|
||||
{
|
||||
@ -268,7 +268,7 @@
|
||||
"tags": [
|
||||
"t"
|
||||
],
|
||||
"description": "get all Datas",
|
||||
"description": "get all Datas\n\u003cbr\u003e",
|
||||
"operationId": "TableController.GetAllTableColumn",
|
||||
"parameters": [
|
||||
{
|
||||
@ -301,7 +301,7 @@
|
||||
"tags": [
|
||||
"t"
|
||||
],
|
||||
"description": "get all Datas",
|
||||
"description": "get all Datas\n\u003cbr\u003e",
|
||||
"operationId": "TableController.GetAllTableColumnRestriction",
|
||||
"parameters": [
|
||||
{
|
||||
@ -341,7 +341,7 @@
|
||||
"tags": [
|
||||
"t"
|
||||
],
|
||||
"description": "get all Datas",
|
||||
"description": "get all Datas\n\u003cbr\u003e",
|
||||
"operationId": "TableController.GetAllTableColumnRestrictionSortkeys",
|
||||
"parameters": [
|
||||
{
|
||||
@ -381,7 +381,7 @@
|
||||
"tags": [
|
||||
"t"
|
||||
],
|
||||
"description": "get all Datas",
|
||||
"description": "get all Datas\n\u003cbr\u003e",
|
||||
"operationId": "TableController.GetAllTableColumnRestrictionSortkeysDir",
|
||||
"parameters": [
|
||||
{
|
||||
|
@ -1,7 +1,8 @@
|
||||
swagger: "2.0"
|
||||
info:
|
||||
title: beego Test API
|
||||
description: beego has a very cool tools to autogenerate documents for your API
|
||||
description: |
|
||||
beego has a very cool tools to autogenerate documents for your API
|
||||
version: 1.0.0
|
||||
termsOfService: http://beego.me/
|
||||
contact:
|
||||
@ -15,7 +16,9 @@ paths:
|
||||
post:
|
||||
tags:
|
||||
- l
|
||||
description: Add user
|
||||
description: |-
|
||||
Add user
|
||||
<br>
|
||||
operationId: LoginController.AddUser
|
||||
parameters:
|
||||
- in: query
|
||||
@ -37,7 +40,9 @@ paths:
|
||||
post:
|
||||
tags:
|
||||
- l
|
||||
description: User login
|
||||
description: |-
|
||||
User login
|
||||
<br>
|
||||
operationId: LoginController.Login
|
||||
parameters:
|
||||
- in: body
|
||||
@ -57,7 +62,9 @@ paths:
|
||||
post:
|
||||
tags:
|
||||
- l
|
||||
description: Logs user
|
||||
description: |-
|
||||
Logs user
|
||||
<br>
|
||||
operationId: LoginController.Logout
|
||||
responses:
|
||||
"200":
|
||||
@ -68,18 +75,22 @@ paths:
|
||||
get:
|
||||
tags:
|
||||
- s
|
||||
description: get list table
|
||||
operationId: SchemaController.GetTable
|
||||
description: |-
|
||||
Get database tables list
|
||||
<br>
|
||||
operationId: SchemaController.GetTablesList
|
||||
responses:
|
||||
"200":
|
||||
description: '{string} success !'
|
||||
"403":
|
||||
description: no table
|
||||
"500":
|
||||
description: query error
|
||||
/s/{table}:
|
||||
get:
|
||||
tags:
|
||||
- s
|
||||
description: get table schema
|
||||
description: |-
|
||||
Get table schema
|
||||
<br>
|
||||
operationId: SchemaController.GetSchema
|
||||
parameters:
|
||||
- in: path
|
||||
@ -90,13 +101,15 @@ paths:
|
||||
responses:
|
||||
"200":
|
||||
description: success !
|
||||
"403":
|
||||
"204":
|
||||
description: no table
|
||||
/t/{table}:
|
||||
get:
|
||||
tags:
|
||||
- t
|
||||
description: get all Datas
|
||||
description: |-
|
||||
get all Datas
|
||||
<br>
|
||||
operationId: TableController.GetAllTable
|
||||
parameters:
|
||||
- in: path
|
||||
@ -112,7 +125,9 @@ paths:
|
||||
put:
|
||||
tags:
|
||||
- t
|
||||
description: put data in table
|
||||
description: |-
|
||||
put data in table
|
||||
<br>
|
||||
operationId: TableController.Put data in table
|
||||
parameters:
|
||||
- in: path
|
||||
@ -134,7 +149,9 @@ paths:
|
||||
post:
|
||||
tags:
|
||||
- t
|
||||
description: get all Datas
|
||||
description: |-
|
||||
get all Datas
|
||||
<br>
|
||||
operationId: TableController.TablePost
|
||||
parameters:
|
||||
- in: path
|
||||
@ -156,7 +173,9 @@ paths:
|
||||
delete:
|
||||
tags:
|
||||
- t
|
||||
description: delete the data in table
|
||||
description: |-
|
||||
delete the data in table
|
||||
<br>
|
||||
operationId: TableController.Delete
|
||||
parameters:
|
||||
- in: path
|
||||
@ -178,7 +197,9 @@ paths:
|
||||
get:
|
||||
tags:
|
||||
- t
|
||||
description: get all Datas
|
||||
description: |-
|
||||
get all Datas
|
||||
<br>
|
||||
operationId: TableController.GetAllTableColumn
|
||||
parameters:
|
||||
- in: path
|
||||
@ -200,7 +221,9 @@ paths:
|
||||
get:
|
||||
tags:
|
||||
- t
|
||||
description: get all Datas
|
||||
description: |-
|
||||
get all Datas
|
||||
<br>
|
||||
operationId: TableController.GetAllTableColumnRestriction
|
||||
parameters:
|
||||
- in: path
|
||||
@ -227,7 +250,9 @@ paths:
|
||||
get:
|
||||
tags:
|
||||
- t
|
||||
description: get all Datas
|
||||
description: |-
|
||||
get all Datas
|
||||
<br>
|
||||
operationId: TableController.GetAllTableColumnRestrictionSortkeys
|
||||
parameters:
|
||||
- in: path
|
||||
@ -254,7 +279,9 @@ paths:
|
||||
get:
|
||||
tags:
|
||||
- t
|
||||
description: get all Datas
|
||||
description: |-
|
||||
get all Datas
|
||||
<br>
|
||||
operationId: TableController.GetAllTableColumnRestrictionSortkeysDir
|
||||
parameters:
|
||||
- in: path
|
||||
|
Loading…
Reference in New Issue
Block a user