Skip to content

Commit

Permalink
docs: improve the documentation of the endpoints 📝 (#13)
Browse files Browse the repository at this point in the history
* fix(docs): server url

* docs: better document default handlers

* docs: better document database related operations

* docs: change tables tag name and add a description

* docs: better document list tables endpoint

* docs: better document getting table info

* docs: better document create table endpoint

* docs: document remaining endpoints

* docs: some small fixes

* docs: better document query descriptions

* docs: finish up documenting graphql operations
  • Loading branch information
kareemmahlees authored Dec 28, 2024
1 parent dfecb91 commit ceeccf9
Show file tree
Hide file tree
Showing 21 changed files with 1,007 additions and 649 deletions.
11 changes: 8 additions & 3 deletions docs/swagger.json

Large diffs are not rendered by default.

355 changes: 297 additions & 58 deletions docs/swagger.yaml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions internal/db/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (p *mysqlProvider) CreateDB(dbName string) error {
}
return nil
}
func (p *mysqlProvider) GetTable(tableName string) ([]*models.TableInfoResp, error) {
func (p *mysqlProvider) GetTable(tableName string) ([]*models.TableColumnInfo, error) {
queryString := `
SELECT column_name AS name,
column_type AS type,
Expand All @@ -58,9 +58,9 @@ func (p *mysqlProvider) GetTable(tableName string) ([]*models.TableInfoResp, err
return nil, err
}
defer rows.Close()
tablesDescriptions := []*models.TableInfoResp{}
tablesDescriptions := []*models.TableColumnInfo{}
for rows.Next() {
tableDesc := new(models.TableInfoResp)
tableDesc := new(models.TableColumnInfo)
err := rows.StructScan(tableDesc)
if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions internal/db/pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (p *pgProvider) CreateDB(dbName string) error {
return nil
}

func (p *pgProvider) GetTable(tableName string) ([]*models.TableInfoResp, error) {
func (p *pgProvider) GetTable(tableName string) ([]*models.TableColumnInfo, error) {
queryString := `
SELECT col.column_name AS name,
col.data_type AS type,
Expand All @@ -61,9 +61,9 @@ func (p *pgProvider) GetTable(tableName string) ([]*models.TableInfoResp, error)
return nil, err
}
defer rows.Close()
tablesDescriptions := []*models.TableInfoResp{}
tablesDescriptions := []*models.TableColumnInfo{}
for rows.Next() {
tableDesc := new(models.TableInfoResp)
tableDesc := new(models.TableColumnInfo)
err := rows.StructScan(tableDesc)
if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions internal/db/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (p *SqliteProvider) CreateDB(dbName string) error {
return errors.New("Unsupported")
}

func (p *SqliteProvider) GetTable(tableName string) ([]*models.TableInfoResp, error) {
func (p *SqliteProvider) GetTable(tableName string) ([]*models.TableColumnInfo, error) {
queryString := `
SELECT name,type,
CASE when 'notnull' = 1
Expand All @@ -63,9 +63,9 @@ func (p *SqliteProvider) GetTable(tableName string) ([]*models.TableInfoResp, er
return nil, err
}
defer rows.Close()
tablesDescriptions := []*models.TableInfoResp{}
tablesDescriptions := []*models.TableColumnInfo{}
for rows.Next() {
tableDesc := new(models.TableInfoResp)
tableDesc := new(models.TableColumnInfo)
err := rows.StructScan(tableDesc)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion internal/db/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type DatabaseExecuter interface {
// Interface that must be implemented by any
// storage driver dealing with table logic
type TableExecuter interface {
GetTable(tableName string) ([]*models.TableInfoResp, error)
GetTable(tableName string) ([]*models.TableColumnInfo, error)
ListTables() ([]*string, error)
CreateTable(tableName string, data []models.CreateTablePayload) error
DeleteTable(tableName string) error
Expand Down
Loading

0 comments on commit ceeccf9

Please sign in to comment.