From 27b85d06269e84b1b00efa88d4c517cd950dc6c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Thu, 20 Jan 2022 23:37:19 +0100 Subject: [PATCH] update api docs --- docs/docs.go | 29 +++++++++++++++++-- pkg/api/controllers/account_controller.go | 6 ++-- pkg/api/controllers/transaction_controller.go | 7 +++-- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 24e7e97aa..b76009fbd 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -54,7 +54,7 @@ var doc = `{ "produces": [ "application/json" ], - "summary": "List All Accounts", + "summary": "List all accounts", "parameters": [ { "type": "string", @@ -62,6 +62,13 @@ var doc = `{ "name": "ledger", "in": "path", "required": true + }, + { + "type": "string", + "description": "pagination cursor, will return accounts after given address (in descending order)", + "name": "after", + "in": "query", + "required": true } ], "responses": { @@ -332,7 +339,7 @@ var doc = `{ }, "/{ledger}/transactions": { "get": { - "description": "Get all ledger transactions\nList transactions", + "description": "Get all ledger transactions", "consumes": [ "application/json" ], @@ -350,6 +357,24 @@ var doc = `{ "name": "ledger", "in": "path", "required": true + }, + { + "type": "string", + "description": "pagination cursor, will return transactions after given txid (in descending order)", + "name": "after", + "in": "query" + }, + { + "type": "string", + "description": "find transactions by reference field", + "name": "reference", + "in": "query" + }, + { + "type": "string", + "description": "find transactions with postings involving given account, either as source or destination", + "name": "account", + "in": "query" } ], "responses": { diff --git a/pkg/api/controllers/account_controller.go b/pkg/api/controllers/account_controller.go index fe08c57be..36f725542 100644 --- a/pkg/api/controllers/account_controller.go +++ b/pkg/api/controllers/account_controller.go @@ -1,10 +1,11 @@ package controllers import ( + "net/http" + "github.com/numary/ledger/pkg/core" "github.com/numary/ledger/pkg/ledger" "github.com/numary/ledger/pkg/ledger/query" - "net/http" "github.com/gin-gonic/gin" ) @@ -20,9 +21,10 @@ func NewAccountController() AccountController { } // GetAccounts godoc -// @Summary List All Accounts +// @Summary List all accounts // @Schemes // @Param ledger path string true "ledger" +// @Param after query string true "pagination cursor, will return accounts after given address (in descending order)" // @Accept json // @Produce json // @Success 200 {object} controllers.BaseResponse{cursor=query.Cursor{data=[]core.Account}} diff --git a/pkg/api/controllers/transaction_controller.go b/pkg/api/controllers/transaction_controller.go index 7b6347062..5f294ca7d 100644 --- a/pkg/api/controllers/transaction_controller.go +++ b/pkg/api/controllers/transaction_controller.go @@ -2,9 +2,10 @@ package controllers import ( "errors" - "github.com/numary/ledger/pkg/storage" "net/http" + "github.com/numary/ledger/pkg/storage" + "github.com/gin-gonic/gin" "github.com/numary/ledger/pkg/core" "github.com/numary/ledger/pkg/ledger" @@ -26,8 +27,10 @@ func NewTransactionController() TransactionController { // @Description Get all ledger transactions // @Tags transactions // @Schemes -// @Description List transactions // @Param ledger path string true "ledger" +// @Param after query string false "pagination cursor, will return transactions after given txid (in descending order)" +// @Param reference query string false "find transactions by reference field" +// @Param account query string false "find transactions with postings involving given account, either as source or destination" // @Accept json // @Produce json // @Success 200 {object} controllers.BaseResponse{cursor=query.Cursor{data=[]core.Transaction}}