Skip to content

Commit

Permalink
Initial docs (swagger)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelometal committed Jul 27, 2020
1 parent f8670bd commit 81b1089
Show file tree
Hide file tree
Showing 25 changed files with 4,336 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ run:

clean:
@find . -name "*.swp" -delete

docs-update:
@swag init
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ make setup
make run
```

## Docs

http://localhost:8889/swagger/index.html

## Examples:

* Adding portfolio:
Expand Down
35 changes: 35 additions & 0 deletions api/brokers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import (
log "github.com/sirupsen/logrus"
)

// broker godoc
// @Summary Get a broker
// @Description get all broker data
// @Accept json
// @Produce json
// @Success 200 {object} wallet.Broker
// @Router /brokers/{id} [get]
// @Param id path string true "Broker id"
func (s *server) broker(c echo.Context) error {
id := c.Param("id")
log.Debugf("[API] Retrieving broker id: %s", id)
Expand All @@ -25,6 +33,13 @@ func (s *server) broker(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// brokers godoc
// @Summary List all brokers
// @Description get all brokers data
// @Accept json
// @Produce json
// @Success 200 {array} wallet.Broker
// @Router /brokers [get]
func (s *server) brokers(c echo.Context) error {
log.Debug("Retrieving all brokers")

Expand All @@ -36,6 +51,12 @@ func (s *server) brokers(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// brokersAdd godoc
// @Summary Insert some broker
// @Description insert new broker
// @Accept json
// @Produce json
// @Router /brokers [post]
func (s *server) brokersAdd(c echo.Context) error {
log.Debug("Insert brokers data")

Expand All @@ -58,6 +79,13 @@ func (s *server) brokersAdd(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// brokersDelete godoc
// @Summary Delete broker by ID
// @Description delete some broker by id
// @Accept json
// @Produce json
// @Router /brokers/{id} [delete]
// @Param id path string true "Broker id"
func (s *server) brokersDelete(c echo.Context) error {
id := c.Param("id")
log.Debugf("Deleting %s data", id)
Expand All @@ -68,6 +96,13 @@ func (s *server) brokersDelete(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// brokersUpdate godoc
// @Summary Update broker data by ID
// @Description Update some broker by id
// @Accept json
// @Produce json
// @Router /brokers/{id} [put]
// @Param id path string true "Broker id"
func (s *server) brokersUpdate(c echo.Context) error {
id := c.Param("id")
log.Debugf("Updating %s data", id)
Expand Down
21 changes: 21 additions & 0 deletions api/certificates_of_deposit_purchases.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ func (s *server) getAllCertificatesOfDepositPurchases(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// getCertificateOfDepositPurchaseByID godoc
// @Summary Get get certificate of deposit purchase by ID
// @Description get certificate of deposi purchase data
// @Accept json
// @Produce json
// @Success 200 {object} wallet.CertificateOfDeposit
// @Router /certificate-of-deposit/purchases/{id} [get]
// @Param id path string true "Purchase id"
func (s *server) getCertificateOfDepositPurchaseByID(c echo.Context) error {
id := c.Param("id")
log.Debugf("[API] Retrieving certificate of deposit purchase with id: %s", id)
Expand All @@ -35,6 +43,12 @@ func (s *server) getCertificateOfDepositPurchaseByID(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// insertCertificateOfDepositPurchase godoc
// @Summary Insert some certificate of deposit purchase
// @Description insert new certificate of deposit purchase
// @Accept json
// @Produce json
// @Router /certificate-of-deposit/purchases [post]
func (s *server) insertCertificateOfDepositPurchase(c echo.Context) error {
log.Debugf("[API] Inserting certificate of deposit purchase")

Expand All @@ -59,6 +73,13 @@ func (s *server) insertCertificateOfDepositPurchase(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// updateCertificateOfDepositPurchaseByID godoc
// @Summary Update some certificate of deposit purchase
// @Description update new certificate of deposit purchase
// @Accept json
// @Produce json
// @Router /certificate-of-deposit/purchases/{id} [put]
// @Param id path string true "Purchase id"
func (s *server) updateCertificateOfDepositPurchaseByID(c echo.Context) error {
id := c.Param("id")
log.Debugf("[API] Updating certificate of deposit purchase with id %s", id)
Expand Down
21 changes: 21 additions & 0 deletions api/certificates_of_deposit_sales.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ func (s *server) getAllCertificatesOfDepositSales(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// getCertificateOfDepositSaleByID godoc
// @Summary Get get certificate of deposit sale by ID
// @Description get certificate of deposit sale data
// @Accept json
// @Produce json
// @Success 200 {object} wallet.CertificateOfDeposit
// @Router /certificates-of-deposit/sales/{id} [get]
// @Param id path string true "Sale id"
func (s *server) getCertificateOfDepositSaleByID(c echo.Context) error {
id := c.Param("id")
log.Debugf("[API] Retrieving certificate of deposit sale with id: %s", id)
Expand All @@ -35,6 +43,12 @@ func (s *server) getCertificateOfDepositSaleByID(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// insertCertificateOfDepositSale godoc
// @Summary Insert some certificate of deposit sale
// @Description insert new certificate of deposit sale
// @Accept json
// @Produce json
// @Router /certificates-of-deposit/sales [post]
func (s *server) insertCertificateOfDepositSale(c echo.Context) error {
log.Debugf("[API] Inserting certificate of deposit sale")

Expand All @@ -59,6 +73,13 @@ func (s *server) insertCertificateOfDepositSale(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// updateCertificateOfDepositSaleByID godoc
// @Summary Update some certificate of deposit sale
// @Description update new certificate of deposit sale
// @Accept json
// @Produce json
// @Router /certificates-of-deposit/sales/{id} [put]
// @Param id path string true "Sale id"
func (s *server) updateCertificateOfDepositSaleByID(c echo.Context) error {
id := c.Param("id")
log.Debugf("[API] Updating certificate of deposit sale with id %s", id)
Expand Down
21 changes: 21 additions & 0 deletions api/ficfi_purchases.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ func (s *server) getAllFICFIPurchases(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// getFICFIPurchaseByID godoc
// @Summary Get FICFI purchase by ID
// @Description get FIFCI purchase data
// @Accept json
// @Produce json
// @Success 200 {object} wallet.FICFI
// @Router /ficfi/purchases/{id} [get]
// @Param id path string true "Purchase id"
func (s *server) getFICFIPurchaseByID(c echo.Context) error {
id := c.Param("id")
log.Debugf("[API] Retrieving FICFI purchase with id: %s", id)
Expand All @@ -35,6 +43,12 @@ func (s *server) getFICFIPurchaseByID(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// insertFICFIPurchase godoc
// @Summary Insert some FICFI purchase
// @Description insert new FICFI purchase
// @Accept json
// @Produce json
// @Router /ficfi/purchases [post]
func (s *server) insertFICFIPurchase(c echo.Context) error {
log.Debugf("[API] Inserting FICFI purchase")

Expand All @@ -59,6 +73,13 @@ func (s *server) insertFICFIPurchase(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// updateFICFIPurchaseByID godoc
// @Summary Update some FICFI purchase
// @Description update new FICFI purchase
// @Accept json
// @Produce json
// @Router /ficfi/purchases/{id} [put]
// @Param id path string true "Purchase id"
func (s *server) updateFICFIPurchaseByID(c echo.Context) error {
id := c.Param("id")
log.Debugf("[API] Updating FICFI purchase with id %s", id)
Expand Down
21 changes: 21 additions & 0 deletions api/ficfi_sales.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ func (s *server) getAllFICFISales(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// getFICFISaleByID godoc
// @Summary Get FICFI sale by ID
// @Description get FICFI sale data
// @Accept json
// @Produce json
// @Success 200 {object} wallet.FICFI
// @Router /ficfi/sales/{id} [get]
// @Param id path string true "Sale id"
func (s *server) getFICFISaleByID(c echo.Context) error {
id := c.Param("id")
log.Debugf("[API] Retrieving FICFI sale with id: %s", id)
Expand All @@ -35,6 +43,12 @@ func (s *server) getFICFISaleByID(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// insertFICFISale godoc
// @Summary Insert some FICFI sale
// @Description insert new FICFI sale
// @Accept json
// @Produce json
// @Router /ficfi/sales [post]
func (s *server) insertFICFISale(c echo.Context) error {
log.Debugf("[API] Inserting FICFI sale")

Expand All @@ -59,6 +73,13 @@ func (s *server) insertFICFISale(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// updateFICFISaleByID godoc
// @Summary Update some FICFI sale
// @Description update new FICFI sale
// @Accept json
// @Produce json
// @Router /ficfi/sales/{id} [put]
// @Param id path string true "Sale id"
func (s *server) updateFICFISaleByID(c echo.Context) error {
id := c.Param("id")
log.Debugf("[API] Updating FICFI sale with id %s", id)
Expand Down
21 changes: 21 additions & 0 deletions api/fiis_purchases.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ func (s *server) getAllFIIsPurchases(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// getFIIPurchaseByID godoc
// @Summary Get FII purchase by ID
// @Description get FII purchase data
// @Accept json
// @Produce json
// @Success 200 {object} wallet.FII
// @Router /fiis/purchases/{id} [get]
// @Param id path string true "Purchase id"
func (s *server) getFIIPurchaseByID(c echo.Context) error {
id := c.Param("id")
log.Debugf("[API] Retrieving stock purchase with id: %s", id)
Expand All @@ -35,6 +43,12 @@ func (s *server) getFIIPurchaseByID(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// insertFIIPurchase godoc
// @Summary Insert some FII purchase
// @Description insert new FII purchase
// @Accept json
// @Produce json
// @Router /fiis/purchases [post]
func (s *server) insertFIIPurchase(c echo.Context) error {
log.Debugf("[API] Inserting stock purchase")

Expand All @@ -59,6 +73,13 @@ func (s *server) insertFIIPurchase(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// updateFIIPurchaseByID godoc
// @Summary Update some FII purchase
// @Description update new FII purchase
// @Accept json
// @Produce json
// @Router /fiis/purchases/{id} [put]
// @Param id path string true "Purchase id"
func (s *server) updateFIIPurchaseByID(c echo.Context) error {
id := c.Param("id")
log.Debugf("[API] Updating stock purchase with id %s", id)
Expand Down
21 changes: 21 additions & 0 deletions api/fiis_sales.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ func (s *server) getAllFIISales(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// getFIISaleByID godoc
// @Summary Get FII sale by ID
// @Description get FII sale data
// @Accept json
// @Produce json
// @Success 200 {object} wallet.FII
// @Router /fiis/sales/{id} [get]
// @Param id path string true "Sale id"
func (s *server) getFIISaleByID(c echo.Context) error {
id := c.Param("id")
log.Debugf("[API] Retrieving stock sale with id: %s", id)
Expand All @@ -35,6 +43,12 @@ func (s *server) getFIISaleByID(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// insertFIISale godoc
// @Summary Insert some FII sale
// @Description insert new FII sale
// @Accept json
// @Produce json
// @Router /fiis/sales [post]
func (s *server) insertFIISale(c echo.Context) error {
log.Debugf("[API] Inserting stock sale")

Expand All @@ -59,6 +73,13 @@ func (s *server) insertFIISale(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// updateFIISaleByID godoc
// @Summary Update some FII sale
// @Description update new FII sale
// @Accept json
// @Produce json
// @Router /fiis/sales/{id} [put]
// @Param id path string true "Sale id"
func (s *server) updateFIISaleByID(c echo.Context) error {
id := c.Param("id")
log.Debugf("[API] Updating stock sale with id %s", id)
Expand Down
Loading

0 comments on commit 81b1089

Please sign in to comment.