From 1e2c606819f154a085a3bd223b4aef1d8b114e19 Mon Sep 17 00:00:00 2001 From: Brecci Date: Mon, 25 Nov 2024 15:39:04 -0300 Subject: [PATCH 1/4] fix: adjust ledger swagger docs :bug: --- common/net/http/withBody.go | 29 --- common/net/http/withLogging.go | 4 + components/ledger/api/docs.go | 210 ++++++++++++++++ components/ledger/api/swagger.json | 210 ++++++++++++++++ components/ledger/api/swagger.yaml | 140 +++++++++++ components/ledger/cmd/app/main.go | 20 +- .../database/postgres/product/product.go | 2 +- .../ledger/internal/bootstrap/http/account.go | 226 +++++++++--------- .../ledger/internal/bootstrap/http/asset.go | 99 ++++---- .../ledger/internal/bootstrap/http/ledger.go | 87 +++---- .../internal/bootstrap/http/organization.go | 79 +++--- .../internal/bootstrap/http/portfolio.go | 97 ++++---- .../ledger/internal/bootstrap/http/product.go | 99 ++++---- .../ledger/internal/bootstrap/http/routes.go | 3 +- .../ledger/internal/bootstrap/http/swagger.go | 34 +++ components/ledger/pkg/.keep | 0 16 files changed, 971 insertions(+), 368 deletions(-) create mode 100644 components/ledger/internal/bootstrap/http/swagger.go create mode 100644 components/ledger/pkg/.keep diff --git a/common/net/http/withBody.go b/common/net/http/withBody.go index 59b5f11c..d35feec9 100644 --- a/common/net/http/withBody.go +++ b/common/net/http/withBody.go @@ -4,8 +4,6 @@ import ( "encoding/json" "errors" gold "github.com/LerianStudio/midaz/common/gold/transaction/model" - "github.com/LerianStudio/midaz/components/ledger/api" - "os" "reflect" "regexp" "strconv" @@ -506,30 +504,3 @@ func compareSlices(original, marshaled []any) []any { return diff } - -// WithSwaggerEnvConfig sets the Swagger configuration for the API documentation from environment variables if they are set. -func WithSwaggerEnvConfig() fiber.Handler { - return func(c *fiber.Ctx) error { - envVars := map[string]*string{ - "SWAGGER_TITLE": &api.SwaggerInfo.Title, - "SWAGGER_DESCRIPTION": &api.SwaggerInfo.Description, - "SWAGGER_VERSION": &api.SwaggerInfo.Version, - "SWAGGER_HOST": &api.SwaggerInfo.Host, - "SWAGGER_BASE_PATH": &api.SwaggerInfo.BasePath, - "SWAGGER_LEFT_DELIM": &api.SwaggerInfo.LeftDelim, - "SWAGGER_RIGHT_DELIM": &api.SwaggerInfo.RightDelim, - } - - for env, field := range envVars { - if value := os.Getenv(env); value != "" { - *field = value - } - } - - if schemes := os.Getenv("SWAGGER_SCHEMES"); schemes != "" { - api.SwaggerInfo.Schemes = []string{schemes} - } - - return c.Next() - } -} diff --git a/common/net/http/withLogging.go b/common/net/http/withLogging.go index d5505fb9..cc050e95 100644 --- a/common/net/http/withLogging.go +++ b/common/net/http/withLogging.go @@ -156,6 +156,10 @@ func WithHTTPLogging(opts ...LogMiddlewareOption) fiber.Handler { return c.Next() } + if strings.Contains(c.Path(), "swagger") && c.Path() != "/swagger/index.html" { + return c.Next() + } + setRequestMidazID(c) info := NewRequestInfo(c) diff --git a/components/ledger/api/docs.go b/components/ledger/api/docs.go index 4cf804d9..a4c3b135 100644 --- a/components/ledger/api/docs.go +++ b/components/ledger/api/docs.go @@ -39,6 +39,12 @@ const docTemplate = `{ "description": "Metadata", "name": "metadata", "in": "query" + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -86,6 +92,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/CreateOrganizationInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -115,6 +127,12 @@ const docTemplate = `{ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -139,6 +157,12 @@ const docTemplate = `{ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -175,6 +199,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/UpdateOrganizationInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -211,6 +241,12 @@ const docTemplate = `{ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -265,6 +301,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/CreateLedgerInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -294,6 +336,12 @@ const docTemplate = `{ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -325,6 +373,12 @@ const docTemplate = `{ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -368,6 +422,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/UpdateLedgerInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -410,6 +470,12 @@ const docTemplate = `{ "description": "Metadata", "name": "metadata", "in": "query" + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -471,6 +537,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/CreateAccountInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -514,6 +586,12 @@ const docTemplate = `{ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -552,6 +630,12 @@ const docTemplate = `{ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -602,6 +686,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/UpdateAccountInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -644,6 +734,12 @@ const docTemplate = `{ "description": "Metadata", "name": "metadata", "in": "query" + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -705,6 +801,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/CreateAssetInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -748,6 +850,12 @@ const docTemplate = `{ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -786,6 +894,12 @@ const docTemplate = `{ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -836,6 +950,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/UpdateAssetInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -878,6 +998,12 @@ const docTemplate = `{ "description": "Metadata query", "name": "metadata", "in": "query" + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -939,6 +1065,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/CreatePortfolioInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -982,6 +1114,12 @@ const docTemplate = `{ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1020,6 +1158,12 @@ const docTemplate = `{ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1063,6 +1207,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/UpdatePortfolioInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1112,6 +1262,12 @@ const docTemplate = `{ "description": "Metadata", "name": "metadata", "in": "query" + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1180,6 +1336,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/CreateAccountInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1230,6 +1392,12 @@ const docTemplate = `{ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1268,6 +1436,12 @@ const docTemplate = `{ "name": "portfolio_id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1325,6 +1499,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/UpdateAccountInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1367,6 +1547,12 @@ const docTemplate = `{ "description": "Metadata", "name": "metadata", "in": "query" + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1428,6 +1614,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/CreateProductInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1471,6 +1663,12 @@ const docTemplate = `{ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1509,6 +1707,12 @@ const docTemplate = `{ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1559,6 +1763,12 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/UpdateProductInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { diff --git a/components/ledger/api/swagger.json b/components/ledger/api/swagger.json index 0ca63ac4..6697a9c8 100644 --- a/components/ledger/api/swagger.json +++ b/components/ledger/api/swagger.json @@ -33,6 +33,12 @@ "description": "Metadata", "name": "metadata", "in": "query" + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -80,6 +86,12 @@ "schema": { "$ref": "#/definitions/CreateOrganizationInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -109,6 +121,12 @@ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -133,6 +151,12 @@ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -169,6 +193,12 @@ "schema": { "$ref": "#/definitions/UpdateOrganizationInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -205,6 +235,12 @@ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -259,6 +295,12 @@ "schema": { "$ref": "#/definitions/CreateLedgerInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -288,6 +330,12 @@ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -319,6 +367,12 @@ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -362,6 +416,12 @@ "schema": { "$ref": "#/definitions/UpdateLedgerInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -404,6 +464,12 @@ "description": "Metadata", "name": "metadata", "in": "query" + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -465,6 +531,12 @@ "schema": { "$ref": "#/definitions/CreateAccountInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -508,6 +580,12 @@ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -546,6 +624,12 @@ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -596,6 +680,12 @@ "schema": { "$ref": "#/definitions/UpdateAccountInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -638,6 +728,12 @@ "description": "Metadata", "name": "metadata", "in": "query" + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -699,6 +795,12 @@ "schema": { "$ref": "#/definitions/CreateAssetInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -742,6 +844,12 @@ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -780,6 +888,12 @@ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -830,6 +944,12 @@ "schema": { "$ref": "#/definitions/UpdateAssetInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -872,6 +992,12 @@ "description": "Metadata query", "name": "metadata", "in": "query" + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -933,6 +1059,12 @@ "schema": { "$ref": "#/definitions/CreatePortfolioInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -976,6 +1108,12 @@ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1014,6 +1152,12 @@ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1057,6 +1201,12 @@ "schema": { "$ref": "#/definitions/UpdatePortfolioInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1106,6 +1256,12 @@ "description": "Metadata", "name": "metadata", "in": "query" + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1174,6 +1330,12 @@ "schema": { "$ref": "#/definitions/CreateAccountInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1224,6 +1386,12 @@ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1262,6 +1430,12 @@ "name": "portfolio_id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1319,6 +1493,12 @@ "schema": { "$ref": "#/definitions/UpdateAccountInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1361,6 +1541,12 @@ "description": "Metadata", "name": "metadata", "in": "query" + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1422,6 +1608,12 @@ "schema": { "$ref": "#/definitions/CreateProductInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1465,6 +1657,12 @@ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1503,6 +1701,12 @@ "name": "id", "in": "path", "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { @@ -1553,6 +1757,12 @@ "schema": { "$ref": "#/definitions/UpdateProductInput" } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" } ], "responses": { diff --git a/components/ledger/api/swagger.yaml b/components/ledger/api/swagger.yaml index 3c36e783..bb5f9c84 100644 --- a/components/ledger/api/swagger.yaml +++ b/components/ledger/api/swagger.yaml @@ -563,6 +563,10 @@ paths: in: query name: metadata type: string + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -591,6 +595,10 @@ paths: required: true schema: $ref: '#/definitions/CreateOrganizationInput' + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -610,6 +618,10 @@ paths: name: id required: true type: string + - description: Request ID + in: header + name: Midaz-Id + type: string responses: "204": description: No Content @@ -624,6 +636,10 @@ paths: name: id required: true type: string + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -650,6 +666,10 @@ paths: required: true schema: $ref: '#/definitions/UpdateOrganizationInput' + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -674,6 +694,10 @@ paths: name: id required: true type: string + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -707,6 +731,10 @@ paths: required: true schema: $ref: '#/definitions/CreateLedgerInput' + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -731,6 +759,10 @@ paths: name: id required: true type: string + - description: Request ID + in: header + name: Midaz-Id + type: string responses: "204": description: No Content @@ -745,6 +777,10 @@ paths: name: id required: true type: string + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -776,6 +812,10 @@ paths: required: true schema: $ref: '#/definitions/UpdateLedgerInput' + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -804,6 +844,10 @@ paths: in: query name: metadata type: string + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -842,6 +886,10 @@ paths: required: true schema: $ref: '#/definitions/CreateAccountInput' + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -871,6 +919,10 @@ paths: name: id required: true type: string + - description: Request ID + in: header + name: Midaz-Id + type: string responses: "204": description: No Content @@ -895,6 +947,10 @@ paths: name: id required: true type: string + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -931,6 +987,10 @@ paths: required: true schema: $ref: '#/definitions/UpdateAccountInput' + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -959,6 +1019,10 @@ paths: in: query name: metadata type: string + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -997,6 +1061,10 @@ paths: required: true schema: $ref: '#/definitions/CreateAssetInput' + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -1026,6 +1094,10 @@ paths: name: id required: true type: string + - description: Request ID + in: header + name: Midaz-Id + type: string responses: "204": description: No Content @@ -1050,6 +1122,10 @@ paths: name: id required: true type: string + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -1086,6 +1162,10 @@ paths: required: true schema: $ref: '#/definitions/UpdateAssetInput' + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -1114,6 +1194,10 @@ paths: in: query name: metadata type: string + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -1152,6 +1236,10 @@ paths: required: true schema: $ref: '#/definitions/CreatePortfolioInput' + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -1181,6 +1269,10 @@ paths: name: id required: true type: string + - description: Request ID + in: header + name: Midaz-Id + type: string responses: "204": description: No Content @@ -1205,6 +1297,10 @@ paths: name: id required: true type: string + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -1236,6 +1332,10 @@ paths: required: true schema: $ref: '#/definitions/UpdatePortfolioInput' + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -1272,6 +1372,10 @@ paths: in: query name: metadata type: string + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -1318,6 +1422,10 @@ paths: required: true schema: $ref: '#/definitions/CreateAccountInput' + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -1350,6 +1458,10 @@ paths: name: portfolio_id required: true type: string + - description: Request ID + in: header + name: Midaz-Id + type: string responses: "204": description: No Content @@ -1382,6 +1494,10 @@ paths: name: id required: true type: string + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -1426,6 +1542,10 @@ paths: required: true schema: $ref: '#/definitions/UpdateAccountInput' + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -1454,6 +1574,10 @@ paths: in: query name: metadata type: string + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -1492,6 +1616,10 @@ paths: required: true schema: $ref: '#/definitions/CreateProductInput' + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -1521,6 +1649,10 @@ paths: name: id required: true type: string + - description: Request ID + in: header + name: Midaz-Id + type: string responses: "204": description: No Content @@ -1545,6 +1677,10 @@ paths: name: id required: true type: string + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: @@ -1581,6 +1717,10 @@ paths: required: true schema: $ref: '#/definitions/UpdateProductInput' + - description: Request ID + in: header + name: Midaz-Id + type: string produces: - application/json responses: diff --git a/components/ledger/cmd/app/main.go b/components/ledger/cmd/app/main.go index eabbf9a3..4cd09ace 100644 --- a/components/ledger/cmd/app/main.go +++ b/components/ledger/cmd/app/main.go @@ -5,16 +5,16 @@ import ( "github.com/LerianStudio/midaz/components/ledger/internal/bootstrap" ) -// @title Midaz Ledger API -// @version 1.0 -// @description This is a swagger documentation for the Midaz Ledger API -// @termsOfService http://swagger.io/terms/ -// @contact.name Discord community -// @contact.url https://discord.gg/DnhqKwkGv3 -// @license.name Apache 2.0 -// @license.url http://www.apache.org/licenses/LICENSE-2.0.html -// @host localhost:3000 -// @BasePath / +// @title Midaz Ledger API +// @version 1.0 +// @description This is a swagger documentation for the Midaz Ledger API +// @termsOfService http://swagger.io/terms/ +// @contact.name Discord community +// @contact.url https://discord.gg/DnhqKwkGv3 +// @license.name Apache 2.0 +// @license.url http://www.apache.org/licenses/LICENSE-2.0.html +// @host localhost:3000 +// @BasePath / func main() { common.InitLocalEnvConfig() bootstrap.InitServers().Run() diff --git a/components/ledger/internal/adapters/database/postgres/product/product.go b/components/ledger/internal/adapters/database/postgres/product/product.go index a81b991a..14a28bb1 100644 --- a/components/ledger/internal/adapters/database/postgres/product/product.go +++ b/components/ledger/internal/adapters/database/postgres/product/product.go @@ -3,7 +3,7 @@ package product import ( "database/sql" "time" - + "github.com/LerianStudio/midaz/common" "github.com/LerianStudio/midaz/common/mmodel" ) diff --git a/components/ledger/internal/bootstrap/http/account.go b/components/ledger/internal/bootstrap/http/account.go index d45ca85c..d39cdd5e 100644 --- a/components/ledger/internal/bootstrap/http/account.go +++ b/components/ledger/internal/bootstrap/http/account.go @@ -21,16 +21,17 @@ type AccountHandler struct { // CreateAccount is a method that creates account information. // -// @Summary Create an Account -// @Description Create an Account with the input payload -// @Tags Accounts -// @Accept json -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param account body mmodel.CreateAccountInput true "Account" -// @Success 200 {object} mmodel.Account -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts [post] +// @Summary Create an Account +// @Description Create an Account with the input payload +// @Tags Accounts +// @Accept json +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param account body mmodel.CreateAccountInput true "Account" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Account +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts [post] func (handler *AccountHandler) CreateAccount(i any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -71,15 +72,16 @@ func (handler *AccountHandler) CreateAccount(i any, c *fiber.Ctx) error { // GetAllAccounts is a method that retrieves all Accounts. // -// @Summary Get all Accounts -// @Description Get all Accounts with the input metadata or without metadata -// @Tags Accounts -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param metadata query string false "Metadata" -// @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Account} -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts [get] +// @Summary Get all Accounts +// @Description Get all Accounts with the input metadata or without metadata +// @Tags Accounts +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param metadata query string false "Metadata" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Account} +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts [get] func (handler *AccountHandler) GetAllAccounts(c *fiber.Ctx) error { ctx := c.UserContext() @@ -149,15 +151,16 @@ func (handler *AccountHandler) GetAllAccounts(c *fiber.Ctx) error { // GetAccountByID is a method that retrieves Account information by a given account id. // -// @Summary Get an Account by ID -// @Description Get an Account with the input ID -// @Tags Accounts -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param id path string true "Account ID" -// @Success 200 {object} mmodel.Account -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{id} [get] +// @Summary Get an Account by ID +// @Description Get an Account with the input ID +// @Tags Accounts +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param id path string true "Account ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Account +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{id} [get] func (handler *AccountHandler) GetAccountByID(c *fiber.Ctx) error { ctx := c.UserContext() @@ -189,17 +192,18 @@ func (handler *AccountHandler) GetAccountByID(c *fiber.Ctx) error { // UpdateAccount is a method that updates Account information. // -// @Summary Update an Account -// @Description Update an Account with the input payload -// @Tags Accounts -// @Accept json -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param id path string true "Account ID" -// @Param account body mmodel.UpdateAccountInput true "Account" -// @Success 200 {object} mmodel.Account -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{id} [patch] +// @Summary Update an Account +// @Description Update an Account with the input payload +// @Tags Accounts +// @Accept json +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param id path string true "Account ID" +// @Param account body mmodel.UpdateAccountInput true "Account" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Account +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{id} [patch] func (handler *AccountHandler) UpdateAccount(i any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -250,14 +254,15 @@ func (handler *AccountHandler) UpdateAccount(i any, c *fiber.Ctx) error { // DeleteAccountByID is a method that removes Account information by a given account id. // -// @Summary Delete an Account by ID -// @Description Delete an Account with the input ID -// @Tags Accounts -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param id path string true "Account ID" -// @Success 204 -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{id} [delete] +// @Summary Delete an Account by ID +// @Description Delete an Account with the input ID +// @Tags Accounts +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param id path string true "Account ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 204 +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{id} [delete] func (handler *AccountHandler) DeleteAccountByID(c *fiber.Ctx) error { ctx := c.UserContext() @@ -292,19 +297,20 @@ func (handler *AccountHandler) DeleteAccountByID(c *fiber.Ctx) error { // // Will be deprecated in the future. Use CreateAccount instead. // -// @Summary Create an Account from Portfolio -// @Description ## This endpoint will be deprecated soon. Use Create an Account instead. ## -// @Description --- -// @Description Create an Account with the input payload from a Portfolio -// @Tags Accounts -// @Accept json -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param portfolio_id path string true "Portfolio ID" -// @Param account body mmodel.CreateAccountInput true "Account" -// @Success 200 {object} mmodel.Account -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/accounts [post] +// @Summary Create an Account from Portfolio +// @Description ## This endpoint will be deprecated soon. Use Create an Account instead. ## +// @Description --- +// @Description Create an Account with the input payload from a Portfolio +// @Tags Accounts +// @Accept json +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param portfolio_id path string true "Portfolio ID" +// @Param account body mmodel.CreateAccountInput true "Account" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Account +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/accounts [post] func (handler *AccountHandler) CreateAccountFromPortfolio(i any, c *fiber.Ctx) error { ctx := c.UserContext() logger := common.NewLoggerFromContext(ctx) @@ -335,18 +341,19 @@ func (handler *AccountHandler) CreateAccountFromPortfolio(i any, c *fiber.Ctx) e // // Will be deprecated in the future. Use GetAllAccounts instead. // -// @Summary Get all Accounts from Portfolio -// @Description ## This endpoint will be deprecated soon. Use Get all Accounts instead. ## -// @Description --- -// @Description Get all Accounts with the input metadata or without metadata from a Portfolio -// @Tags Accounts -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param portfolio_id path string true "Portfolio ID" -// @Param metadata query string false "Metadata" -// @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Account} -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/accounts [get] +// @Summary Get all Accounts from Portfolio +// @Description ## This endpoint will be deprecated soon. Use Get all Accounts instead. ## +// @Description --- +// @Description Get all Accounts with the input metadata or without metadata from a Portfolio +// @Tags Accounts +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param portfolio_id path string true "Portfolio ID" +// @Param metadata query string false "Metadata" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Account} +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/accounts [get] func (handler *AccountHandler) GetAllAccountsByIDFromPortfolio(c *fiber.Ctx) error { ctx := c.UserContext() logger := common.NewLoggerFromContext(ctx) @@ -403,18 +410,19 @@ func (handler *AccountHandler) GetAllAccountsByIDFromPortfolio(c *fiber.Ctx) err // // Will be deprecated in the future. Use GetAccountByID instead. // -// @Summary Get an Account by ID from Portfolio -// @Description ## This endpoint will be deprecated soon. Use Get an Account by ID instead. ## -// @Description --- -// @Description Get an Account with the input ID from a Portfolio. -// @Tags Accounts -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param portfolio_id path string true "Portfolio ID" -// @Param id path string true "Account ID" -// @Success 200 {object} mmodel.Account -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/accounts/{id} [get] +// @Summary Get an Account by ID from Portfolio +// @Description ## This endpoint will be deprecated soon. Use Get an Account by ID instead. ## +// @Description --- +// @Description Get an Account with the input ID from a Portfolio. +// @Tags Accounts +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param portfolio_id path string true "Portfolio ID" +// @Param id path string true "Account ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Account +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/accounts/{id} [get] func (handler *AccountHandler) GetAccountByIDFromPortfolio(c *fiber.Ctx) error { ctx := c.UserContext() @@ -442,20 +450,21 @@ func (handler *AccountHandler) GetAccountByIDFromPortfolio(c *fiber.Ctx) error { // // Will be deprecated in the future. Use UpdateAccount instead. // -// @Summary Update an Account from Portfolio -// @Description ## This endpoint will be deprecated soon. Use Update an Account instead. ## -// @Description --- -// @Description Update an Account with the input payload from a Portfolio -// @Tags Accounts -// @Accept json -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param portfolio_id path string true "Portfolio ID" -// @Param id path string true "Account ID" -// @Param account body mmodel.UpdateAccountInput true "Account" -// @Success 200 {object} mmodel.Account -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/accounts/{id} [patch] +// @Summary Update an Account from Portfolio +// @Description ## This endpoint will be deprecated soon. Use Update an Account instead. ## +// @Description --- +// @Description Update an Account with the input payload from a Portfolio +// @Tags Accounts +// @Accept json +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param portfolio_id path string true "Portfolio ID" +// @Param id path string true "Account ID" +// @Param account body mmodel.UpdateAccountInput true "Account" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Account +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/accounts/{id} [patch] func (handler *AccountHandler) UpdateAccountFromPortfolio(i any, c *fiber.Ctx) error { ctx := c.UserContext() logger := common.NewLoggerFromContext(ctx) @@ -493,16 +502,17 @@ func (handler *AccountHandler) UpdateAccountFromPortfolio(i any, c *fiber.Ctx) e // // Will be deprecated in the future. Use DeleteAccountByID instead. // -// @Summary Delete an Account by ID from Portfolio -// @Description ## This endpoint will be deprecated soon. Use Delete an Account by ID instead. ## -// @Description --- -// @Description Delete an Account with the input ID from a Portfolio -// @Tags Accounts -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param portfolio_id path string true "Portfolio ID" -// @Success 204 -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/accounts/{id} [delete] +// @Summary Delete an Account by ID from Portfolio +// @Description ## This endpoint will be deprecated soon. Use Delete an Account by ID instead. ## +// @Description --- +// @Description Delete an Account with the input ID from a Portfolio +// @Tags Accounts +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param portfolio_id path string true "Portfolio ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 204 +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/accounts/{id} [delete] func (handler *AccountHandler) DeleteAccountByIDFromPortfolio(c *fiber.Ctx) error { ctx := c.UserContext() logger := common.NewLoggerFromContext(ctx) diff --git a/components/ledger/internal/bootstrap/http/asset.go b/components/ledger/internal/bootstrap/http/asset.go index 568ebec2..9736c98f 100644 --- a/components/ledger/internal/bootstrap/http/asset.go +++ b/components/ledger/internal/bootstrap/http/asset.go @@ -21,16 +21,17 @@ type AssetHandler struct { // CreateAsset is a method that creates asset information. // -// @Summary Create an Asset -// @Description Create an Asset with the input payload -// @Tags Assets -// @Accept json -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param asset body mmodel.CreateAssetInput true "Asset Input" -// @Success 200 {object} mmodel.Asset -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/assets [post] +// @Summary Create an Asset +// @Description Create an Asset with the input payload +// @Tags Assets +// @Accept json +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param asset body mmodel.CreateAssetInput true "Asset Input" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Asset +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/assets [post] func (handler *AssetHandler) CreateAsset(a any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -72,15 +73,16 @@ func (handler *AssetHandler) CreateAsset(a any, c *fiber.Ctx) error { // GetAllAssets is a method that retrieves all Assets. // -// @Summary Get all Assets -// @Description Get all Assets with the input metadata or without metadata -// @Tags Assets -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param metadata query string false "Metadata" -// @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Asset} -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/assets [get] +// @Summary Get all Assets +// @Description Get all Assets with the input metadata or without metadata +// @Tags Assets +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param metadata query string false "Metadata" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Asset} +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/assets [get] func (handler *AssetHandler) GetAllAssets(c *fiber.Ctx) error { ctx := c.UserContext() @@ -144,15 +146,16 @@ func (handler *AssetHandler) GetAllAssets(c *fiber.Ctx) error { // GetAssetByID is a method that retrieves Asset information by a given id. // -// @Summary Get an Asset by ID -// @Description Get an Asset with the input ID -// @Tags Assets -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param id path string true "Asset ID" -// @Success 200 {object} mmodel.Asset -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/assets/{id} [get] +// @Summary Get an Asset by ID +// @Description Get an Asset with the input ID +// @Tags Assets +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param id path string true "Asset ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Asset +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/assets/{id} [get] func (handler *AssetHandler) GetAssetByID(c *fiber.Ctx) error { ctx := c.UserContext() @@ -184,17 +187,18 @@ func (handler *AssetHandler) GetAssetByID(c *fiber.Ctx) error { // UpdateAsset is a method that updates Asset information. // -// @Summary Update an Asset -// @Description Update an Asset with the input payload -// @Tags Assets -// @Accept json -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param id path string true "Asset ID" -// @Param asset body mmodel.UpdateAssetInput true "Asset Input" -// @Success 200 {object} mmodel.Asset -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/assets/{id} [patch] +// @Summary Update an Asset +// @Description Update an Asset with the input payload +// @Tags Assets +// @Accept json +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param id path string true "Asset ID" +// @Param asset body mmodel.UpdateAssetInput true "Asset Input" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Asset +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/assets/{id} [patch] func (handler *AssetHandler) UpdateAsset(a any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -245,14 +249,15 @@ func (handler *AssetHandler) UpdateAsset(a any, c *fiber.Ctx) error { // DeleteAssetByID is a method that removes Asset information by a given ids. // -// @Summary Delete an Asset by ID -// @Description Delete an Asset with the input ID -// @Tags Assets -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param id path string true "Asset ID" -// @Success 204 -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/assets/{id} [delete] +// @Summary Delete an Asset by ID +// @Description Delete an Asset with the input ID +// @Tags Assets +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param id path string true "Asset ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 204 +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/assets/{id} [delete] func (handler *AssetHandler) DeleteAssetByID(c *fiber.Ctx) error { ctx := c.UserContext() diff --git a/components/ledger/internal/bootstrap/http/ledger.go b/components/ledger/internal/bootstrap/http/ledger.go index c78280f2..41674470 100644 --- a/components/ledger/internal/bootstrap/http/ledger.go +++ b/components/ledger/internal/bootstrap/http/ledger.go @@ -25,15 +25,16 @@ type LedgerHandler struct { // CreateLedger is a method that creates Ledger information. // -// @Summary Create a Ledger -// @Description Create a Ledger with the input payload -// @Tags Ledgers -// @Accept json -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger body mmodel.CreateLedgerInput true "Ledger Input" -// @Success 200 {object} mmodel.Ledger -// @Router /v1/organizations/{organization_id}/ledgers [post] +// @Summary Create a Ledger +// @Description Create a Ledger with the input payload +// @Tags Ledgers +// @Accept json +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger body mmodel.CreateLedgerInput true "Ledger Input" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Ledger +// @Router /v1/organizations/{organization_id}/ledgers [post] func (handler *LedgerHandler) CreateLedger(i any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -70,13 +71,14 @@ func (handler *LedgerHandler) CreateLedger(i any, c *fiber.Ctx) error { // GetLedgerByID is a method that retrieves Ledger information by a given id. // -// @Summary Get a Ledger by ID -// @Description Get a Ledger with the input ID -// @Tags Ledgers -// @Produce json -// @Param id path string true "Ledger ID" -// @Success 200 {object} mmodel.Ledger -// @Router /v1/organizations/{organization_id}/ledgers/{id} [get] +// @Summary Get a Ledger by ID +// @Description Get a Ledger with the input ID +// @Tags Ledgers +// @Produce json +// @Param id path string true "Ledger ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Ledger +// @Router /v1/organizations/{organization_id}/ledgers/{id} [get] func (handler *LedgerHandler) GetLedgerByID(c *fiber.Ctx) error { ctx := c.UserContext() @@ -107,14 +109,15 @@ func (handler *LedgerHandler) GetLedgerByID(c *fiber.Ctx) error { // GetAllLedgers is a method that retrieves all ledgers. // -// @Summary Get all Ledgers -// @Description Get all Ledgers with the input metadata or without metadata -// @Tags Ledgers -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param id path string true "Ledger ID" -// @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Ledger} -// @Router /v1/organizations/{organization_id}/ledgers [get] +// @Summary Get all Ledgers +// @Description Get all Ledgers with the input metadata or without metadata +// @Tags Ledgers +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param id path string true "Ledger ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Ledger} +// @Router /v1/organizations/{organization_id}/ledgers [get] func (handler *LedgerHandler) GetAllLedgers(c *fiber.Ctx) error { ctx := c.UserContext() @@ -174,16 +177,17 @@ func (handler *LedgerHandler) GetAllLedgers(c *fiber.Ctx) error { // UpdateLedger is a method that updates Ledger information. // -// @Summary Update a Ledger -// @Description Update a Ledger with the input payload -// @Tags Ledgers -// @Accept json -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param id path string true "Ledger ID" -// @Param ledger body mmodel.UpdateLedgerInput true "Ledger Input" -// @Success 200 {object} mmodel.Ledger -// @Router /v1/organizations/{organization_id}/ledgers/{id} [patch] +// @Summary Update a Ledger +// @Description Update a Ledger with the input payload +// @Tags Ledgers +// @Accept json +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param id path string true "Ledger ID" +// @Param ledger body mmodel.UpdateLedgerInput true "Ledger Input" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Ledger +// @Router /v1/organizations/{organization_id}/ledgers/{id} [patch] func (handler *LedgerHandler) UpdateLedger(p any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -233,13 +237,14 @@ func (handler *LedgerHandler) UpdateLedger(p any, c *fiber.Ctx) error { // DeleteLedgerByID is a method that removes Ledger information by a given id. // -// @Summary Delete a Ledger by ID -// @Description Delete a Ledger with the input ID -// @Tags Ledgers -// @Param organization_id path string true "Organization ID" -// @Param id path string true "Ledger ID" -// @Success 204 -// @Router /v1/organizations/{organization_id}/ledgers/{id} [delete] +// @Summary Delete a Ledger by ID +// @Description Delete a Ledger with the input ID +// @Tags Ledgers +// @Param organization_id path string true "Organization ID" +// @Param id path string true "Ledger ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 204 +// @Router /v1/organizations/{organization_id}/ledgers/{id} [delete] func (handler *LedgerHandler) DeleteLedgerByID(c *fiber.Ctx) error { ctx := c.UserContext() diff --git a/components/ledger/internal/bootstrap/http/organization.go b/components/ledger/internal/bootstrap/http/organization.go index ac66b60c..5b80459e 100644 --- a/components/ledger/internal/bootstrap/http/organization.go +++ b/components/ledger/internal/bootstrap/http/organization.go @@ -25,14 +25,15 @@ type OrganizationHandler struct { // CreateOrganization is a method that creates Organization information. // -// @Summary Create an Organization -// @Description Create an Organization with the input payload -// @Tags Organizations -// @Accept json -// @Produce json -// @Param organization body mmodel.CreateOrganizationInput true "Organization Input" -// @Success 200 {object} mmodel.Organization -// @Router /v1/organizations [post] +// @Summary Create an Organization +// @Description Create an Organization with the input payload +// @Tags Organizations +// @Accept json +// @Produce json +// @Param organization body mmodel.CreateOrganizationInput true "Organization Input" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Organization +// @Router /v1/organizations [post] func (handler *OrganizationHandler) CreateOrganization(p any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -66,15 +67,16 @@ func (handler *OrganizationHandler) CreateOrganization(p any, c *fiber.Ctx) erro // UpdateOrganization is a method that updates Organization information. // -// @Summary Update an Organization -// @Description Update an Organization with the input payload -// @Tags Organizations -// @Accept json -// @Produce json -// @Param id path string true "Organization ID" -// @Param organization body mmodel.UpdateOrganizationInput true "Organization Input" -// @Success 200 {object} mmodel.Organization -// @Router /v1/organizations/{id} [patch] +// @Summary Update an Organization +// @Description Update an Organization with the input payload +// @Tags Organizations +// @Accept json +// @Produce json +// @Param id path string true "Organization ID" +// @Param organization body mmodel.UpdateOrganizationInput true "Organization Input" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Organization +// @Router /v1/organizations/{id} [patch] func (handler *OrganizationHandler) UpdateOrganization(p any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -122,13 +124,14 @@ func (handler *OrganizationHandler) UpdateOrganization(p any, c *fiber.Ctx) erro // GetOrganizationByID is a method that retrieves Organization information by a given id. // -// @Summary Get an Organization by ID -// @Description Get an Organization with the input ID -// @Tags Organizations -// @Produce json -// @Param id path string true "Organization ID" -// @Success 200 {object} mmodel.Organization -// @Router /v1/organizations/{id} [get] +// @Summary Get an Organization by ID +// @Description Get an Organization with the input ID +// @Tags Organizations +// @Produce json +// @Param id path string true "Organization ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Organization +// @Router /v1/organizations/{id} [get] func (handler *OrganizationHandler) GetOrganizationByID(c *fiber.Ctx) error { ctx := c.UserContext() @@ -157,13 +160,14 @@ func (handler *OrganizationHandler) GetOrganizationByID(c *fiber.Ctx) error { // GetAllOrganizations is a method that retrieves all Organizations. // -// @Summary Get all Organizations -// @Description Get all Organizations with the input metadata or without metadata -// @Tags Organizations -// @Produce json -// @Param metadata query string false "Metadata" -// @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Organization} -// @Router /v1/organizations [get] +// @Summary Get all Organizations +// @Description Get all Organizations with the input metadata or without metadata +// @Tags Organizations +// @Produce json +// @Param metadata query string false "Metadata" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Organization} +// @Router /v1/organizations [get] func (handler *OrganizationHandler) GetAllOrganizations(c *fiber.Ctx) error { ctx := c.UserContext() logger := common.NewLoggerFromContext(ctx) @@ -220,12 +224,13 @@ func (handler *OrganizationHandler) GetAllOrganizations(c *fiber.Ctx) error { // DeleteOrganizationByID is a method that removes Organization information by a given id. // -// @Summary Delete an Organization by ID -// @Description Delete an Organization with the input ID -// @Tags Organizations -// @Param id path string true "Organization ID" -// @Success 204 -// @Router /v1/organizations/{id} [delete] +// @Summary Delete an Organization by ID +// @Description Delete an Organization with the input ID +// @Tags Organizations +// @Param id path string true "Organization ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 204 +// @Router /v1/organizations/{id} [delete] func (handler *OrganizationHandler) DeleteOrganizationByID(c *fiber.Ctx) error { ctx := c.UserContext() diff --git a/components/ledger/internal/bootstrap/http/portfolio.go b/components/ledger/internal/bootstrap/http/portfolio.go index c61cd5eb..291d5b52 100644 --- a/components/ledger/internal/bootstrap/http/portfolio.go +++ b/components/ledger/internal/bootstrap/http/portfolio.go @@ -21,16 +21,17 @@ type PortfolioHandler struct { // CreatePortfolio is a method that creates portfolio information. // -// @Summary Create a Portfolio -// @Description Create a Portfolio with the input payload -// @Tags Portfolios -// @Accept json -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param portfolio body mmodel.CreatePortfolioInput true "Portfolio Payload" -// @Success 200 {object} mmodel.Portfolio -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios [post] +// @Summary Create a Portfolio +// @Description Create a Portfolio with the input payload +// @Tags Portfolios +// @Accept json +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param portfolio body mmodel.CreatePortfolioInput true "Portfolio Payload" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Portfolio +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios [post] func (handler *PortfolioHandler) CreatePortfolio(i any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -70,15 +71,16 @@ func (handler *PortfolioHandler) CreatePortfolio(i any, c *fiber.Ctx) error { // GetAllPortfolios is a method that retrieves all Portfolios. // -// @Summary Get all Portfolios -// @Description Get all Portfolios with the input metadata or without metadata -// @Tags Portfolios -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param metadata query string false "Metadata query" -// @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Portfolio} -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios [get] +// @Summary Get all Portfolios +// @Description Get all Portfolios with the input metadata or without metadata +// @Tags Portfolios +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param metadata query string false "Metadata query" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Portfolio} +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios [get] func (handler *PortfolioHandler) GetAllPortfolios(c *fiber.Ctx) error { ctx := c.UserContext() @@ -140,15 +142,16 @@ func (handler *PortfolioHandler) GetAllPortfolios(c *fiber.Ctx) error { // GetPortfolioByID is a method that retrieves Portfolio information by a given id. // -// @Summary Get a Portfolio by ID -// @Description Get a Portfolio with the input ID -// @Tags Portfolios -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param id path string true "Portfolio ID" -// @Success 200 {object} mmodel.Portfolio -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{id} [get] +// @Summary Get a Portfolio by ID +// @Description Get a Portfolio with the input ID +// @Tags Portfolios +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param id path string true "Portfolio ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Portfolio +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{id} [get] func (handler *PortfolioHandler) GetPortfolioByID(c *fiber.Ctx) error { ctx := c.UserContext() @@ -180,16 +183,17 @@ func (handler *PortfolioHandler) GetPortfolioByID(c *fiber.Ctx) error { // UpdatePortfolio is a method that updates Portfolio information. // -// @Summary Update a Portfolio -// @Description Update a Portfolio with the input payload -// @Tags Portfolios -// @Accept json -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param portfolio body mmodel.UpdatePortfolioInput true "Portfolio Payload" -// @Success 200 {object} mmodel.Portfolio -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{id} [patch] +// @Summary Update a Portfolio +// @Description Update a Portfolio with the input payload +// @Tags Portfolios +// @Accept json +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param portfolio body mmodel.UpdatePortfolioInput true "Portfolio Payload" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Portfolio +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{id} [patch] func (handler *PortfolioHandler) UpdatePortfolio(i any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -240,14 +244,15 @@ func (handler *PortfolioHandler) UpdatePortfolio(i any, c *fiber.Ctx) error { // DeletePortfolioByID is a method that removes Portfolio information by a given ids. // -// @Summary Delete a Portfolio by ID -// @Description Delete a Portfolio with the input ID -// @Tags Portfolios -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param id path string true "Portfolio ID" -// @Success 204 -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{id} [delete] +// @Summary Delete a Portfolio by ID +// @Description Delete a Portfolio with the input ID +// @Tags Portfolios +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param id path string true "Portfolio ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 204 +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{id} [delete] func (handler *PortfolioHandler) DeletePortfolioByID(c *fiber.Ctx) error { ctx := c.UserContext() diff --git a/components/ledger/internal/bootstrap/http/product.go b/components/ledger/internal/bootstrap/http/product.go index 58d16c10..18e2a32b 100644 --- a/components/ledger/internal/bootstrap/http/product.go +++ b/components/ledger/internal/bootstrap/http/product.go @@ -21,16 +21,17 @@ type ProductHandler struct { // CreateProduct is a method that creates product information. // -// @Summary Create a Product -// @Description Create a Product with the input payload -// @Tags Products -// @Accept json -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param product body mmodel.CreateProductInput true "Product" -// @Success 200 {object} mmodel.Product -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/products [post] +// @Summary Create a Product +// @Description Create a Product with the input payload +// @Tags Products +// @Accept json +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param product body mmodel.CreateProductInput true "Product" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Product +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/products [post] func (handler *ProductHandler) CreateProduct(i any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -68,15 +69,16 @@ func (handler *ProductHandler) CreateProduct(i any, c *fiber.Ctx) error { // GetAllProducts is a method that retrieves all Products. // -// @Summary Get all Products -// @Description Get all Products with the input metadata or without metadata -// @Tags Products -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param metadata query string false "Metadata" -// @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Product} -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/products [get] +// @Summary Get all Products +// @Description Get all Products with the input metadata or without metadata +// @Tags Products +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param metadata query string false "Metadata" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Product} +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/products [get] func (handler *ProductHandler) GetAllProducts(c *fiber.Ctx) error { ctx := c.UserContext() @@ -138,15 +140,16 @@ func (handler *ProductHandler) GetAllProducts(c *fiber.Ctx) error { // GetProductByID is a method that retrieves Product information by a given id. // -// @Summary Get a Product by ID -// @Description Get a Product with the input ID -// @Tags Products -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param id path string true "Product ID" -// @Success 200 {object} mmodel.Product -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/products/{id} [get] +// @Summary Get a Product by ID +// @Description Get a Product with the input ID +// @Tags Products +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param id path string true "Product ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Product +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/products/{id} [get] func (handler *ProductHandler) GetProductByID(c *fiber.Ctx) error { ctx := c.UserContext() @@ -177,17 +180,18 @@ func (handler *ProductHandler) GetProductByID(c *fiber.Ctx) error { // UpdateProduct is a method that updates Product information. // -// @Summary Update a Product -// @Description Update a Product with the input payload -// @Tags Products -// @Accept json -// @Produce json -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param id path string true "Product ID" -// @Param product body mmodel.UpdateProductInput true "Product" -// @Success 200 {object} mmodel.Product -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/products/{id} [patch] +// @Summary Update a Product +// @Description Update a Product with the input payload +// @Tags Products +// @Accept json +// @Produce json +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param id path string true "Product ID" +// @Param product body mmodel.UpdateProductInput true "Product" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Product +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/products/{id} [patch] func (handler *ProductHandler) UpdateProduct(i any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -237,14 +241,15 @@ func (handler *ProductHandler) UpdateProduct(i any, c *fiber.Ctx) error { // DeleteProductByID is a method that removes Product information by a given ids. // -// @Summary Delete a Product by ID -// @Description Delete a Product with the input ID -// @Tags Products -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param id path string true "Product ID" -// @Success 204 -// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/products/{id} [delete] +// @Summary Delete a Product by ID +// @Description Delete a Product with the input ID +// @Tags Products +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param id path string true "Product ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 204 +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/products/{id} [delete] func (handler *ProductHandler) DeleteProductByID(c *fiber.Ctx) error { ctx := c.UserContext() diff --git a/components/ledger/internal/bootstrap/http/routes.go b/components/ledger/internal/bootstrap/http/routes.go index 4d7493ae..a8b17efd 100644 --- a/components/ledger/internal/bootstrap/http/routes.go +++ b/components/ledger/internal/bootstrap/http/routes.go @@ -84,8 +84,7 @@ func NewRouter(lg mlog.Logger, tl *mopentelemetry.Telemetry, cc *mcasdoor.Casdoo f.Get("/version", http.Version) // Doc - f.Get("/swagger/*", http.WithSwaggerEnvConfig(), fiberSwagger.WrapHandler) - http.DocAPI("ledger", "Ledger API", f) + f.Get("/swagger/*", WithSwaggerEnvConfig(), fiberSwagger.WrapHandler) f.Use(tlMid.EndTracingSpans) diff --git a/components/ledger/internal/bootstrap/http/swagger.go b/components/ledger/internal/bootstrap/http/swagger.go new file mode 100644 index 00000000..c9ebdb76 --- /dev/null +++ b/components/ledger/internal/bootstrap/http/swagger.go @@ -0,0 +1,34 @@ +package http + +import ( + "github.com/LerianStudio/midaz/components/ledger/api" + "github.com/gofiber/fiber/v2" + "os" +) + +// WithSwaggerEnvConfig sets the Swagger configuration for the API documentation from environment variables if they are set. +func WithSwaggerEnvConfig() fiber.Handler { + return func(c *fiber.Ctx) error { + envVars := map[string]*string{ + "SWAGGER_TITLE": &api.SwaggerInfo.Title, + "SWAGGER_DESCRIPTION": &api.SwaggerInfo.Description, + "SWAGGER_VERSION": &api.SwaggerInfo.Version, + "SWAGGER_HOST": &api.SwaggerInfo.Host, + "SWAGGER_BASE_PATH": &api.SwaggerInfo.BasePath, + "SWAGGER_LEFT_DELIM": &api.SwaggerInfo.LeftDelim, + "SWAGGER_RIGHT_DELIM": &api.SwaggerInfo.RightDelim, + } + + for env, field := range envVars { + if value := os.Getenv(env); value != "" { + *field = value + } + } + + if schemes := os.Getenv("SWAGGER_SCHEMES"); schemes != "" { + api.SwaggerInfo.Schemes = []string{schemes} + } + + return c.Next() + } +} diff --git a/components/ledger/pkg/.keep b/components/ledger/pkg/.keep new file mode 100644 index 00000000..e69de29b From e06a30e360e70079ce66c7f3aeecdd5536c8b134 Mon Sep 17 00:00:00 2001 From: Brecci Date: Mon, 25 Nov 2024 15:41:00 -0300 Subject: [PATCH 2/4] feat: add swagger documentation to transaction service :sparkles: --- common/mmodel/asset.go | 38 ++++++---- common/net/http/doc.go | 25 ------- components/transaction/Dockerfile | 2 +- .../internal/domain/assetrate/assetrate.go | 38 ++++++---- .../internal/domain/operation/operation.go | 71 +++++++++++------- .../domain/transaction/transaction.go | 53 +++++++------ components/transaction/internal/main.go | 20 ++--- .../internal/ports/http/assetrate.go | 28 +++++++ .../internal/ports/http/operation.go | 73 ++++++++++++++++++ .../transaction/internal/ports/http/routes.go | 3 +- .../internal/ports/http/swagger.go | 34 +++++++++ .../internal/ports/http/transaction.go | 75 +++++++++++++++++++ 12 files changed, 340 insertions(+), 120 deletions(-) delete mode 100644 common/net/http/doc.go create mode 100644 components/transaction/internal/ports/http/swagger.go diff --git a/common/mmodel/asset.go b/common/mmodel/asset.go index fc67352b..107ebd9e 100644 --- a/common/mmodel/asset.go +++ b/common/mmodel/asset.go @@ -5,34 +5,38 @@ import "time" // CreateAssetInput is a struct design to encapsulate request create payload data. // // swagger:model CreateAssetInput -// @Description CreateAssetInput is a struct design to encapsulate request create payload data. -// @Param name query string false "Name" e -// @Param type query string false "Type" -// @Param code query string false "Code" -// @Param status query string false "Status" -// @Param metadata query string false "Metadata" +// +// @Description CreateAssetInput is a struct design to encapsulate request create payload da +// @Description CreateAssetInput is a struct design to encapsulate request create payload data. +// @Param name query string false "Name" e +// @Param type query string false "Type" +// @Param code query string false "Code" +// @Param status query string false "Status" +// @Param metadata query string false "Metadata" type CreateAssetInput struct { Name string `json:"name" validate:"max=256" example:"Brazilian Real"` Type string `json:"type" example:"currency"` Code string `json:"code" validate:"required,max=100" example:"BRL"` Status Status `json:"status"` Metadata map[string]any `json:"metadata" validate:"dive,keys,keymax=100,endkeys,nonested,valuemax=2000"` -} // @name CreateAssetInput +} // @name CreateAssetInput // UpdateAssetInput is a struct design to encapsulate request update payload data. // +ncapsulate request update payload // swagger:model UpdateAssetInput -// @Description UpdateAssetInput is a struct design to encapsulate request update payload data. +// @Description UpdateAssetInput is a struct design to encapsulate request update payload data. type UpdateAssetInput struct { Name string `json:"name" validate:"max=256" example:"Bitcoin"` Status Status `json:"status"` Metadata map[string]any `json:"metadata" validate:"dive,keys,keymax=100,endkeys,nonested,valuemax=2000"` -} // @name UpdateAssetInput +} // @name UpdateAssetInput // Asset is a struct designed to encapsulate payload data. // + string // swagger:model Asset -// @Description Asset is a struct designed to encapsulate payload data. +// @Description Asset is a struct designed to encapsulate payload data. type Asset struct { ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"` Name string `json:"name" example:"Brazilian Real"` @@ -45,17 +49,19 @@ type Asset struct { UpdatedAt time.Time `json:"updatedAt" example:"2021-01-01T00:00:00Z"` DeletedAt *time.Time `json:"deletedAt" example:"2021-01-01T00:00:00Z"` Metadata map[string]any `json:"metadata,omitempty"` -} // @name Asset +} // @name Asset // Assets struct to return get all. // +string false "Page" +// // swagger:model Assets -// @Description Assets struct to return get all. -// @Param items query string false "Items" -// @Param page query string false "Page" -// @Param limit query string false "Limit" +// @Description Assets struct to return get all. +// @Param items query string false "Items" +// @Param page query string false "Page" +// @Param limit query string false "Limit" type Assets struct { Items []Asset `json:"items"` Page int `json:"page" example:"1"` Limit int `json:"limit" example:"10"` -} // @name Assets +} // @name Assets diff --git a/common/net/http/doc.go b/common/net/http/doc.go deleted file mode 100644 index 2aa5f5b8..00000000 --- a/common/net/http/doc.go +++ /dev/null @@ -1,25 +0,0 @@ -package http - -import ( - "fmt" - - "github.com/gofiber/fiber/v2" - "github.com/gofiber/swagger" -) - -// DocAPI adds the default documentation route to the API. -// Ex: /{serviceName}/docs -// And adds the swagger route too. -// Ex: /{serviceName}/swagger.yaml -func DocAPI(serviceName, title string, app *fiber.App) { - docURL := fmt.Sprintf("/%s/docs", serviceName) - - app.Get(docURL, func(c *fiber.Ctx) error { - return c.SendFile("./components/ledger/api/v1.yml") - }) - - app.Get("/v1/swagger/*", swagger.New(swagger.Config{ - URL: docURL, - Title: title, - })) -} diff --git a/components/transaction/Dockerfile b/components/transaction/Dockerfile index f968ba35..d4149a07 100644 --- a/components/transaction/Dockerfile +++ b/components/transaction/Dockerfile @@ -7,7 +7,7 @@ COPY . . # Add make, install swag and generate docs RUN apk add --no-cache make \ && go install github.com/swaggo/swag/cmd/swag@latest \ - && make -C components/ledger generate-docs + && make -C components/transaction generate-docs RUN CGO_ENABLE=0 GOOS=linux go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o /app components/transaction/internal/main.go diff --git a/components/transaction/internal/domain/assetrate/assetrate.go b/components/transaction/internal/domain/assetrate/assetrate.go index 02e54eb9..92f0aec3 100644 --- a/components/transaction/internal/domain/assetrate/assetrate.go +++ b/components/transaction/internal/domain/assetrate/assetrate.go @@ -20,28 +20,34 @@ type AssetRatePostgreSQLModel struct { } // CreateAssetRateInput is a struct design to encapsulate payload data. +// +// swagger:model CreateAssetRateInput +// @Description CreateAssetRateInput is a struct design to encapsulate payload data. type CreateAssetRateInput struct { - BaseAssetCode string `json:"baseAssetCode"` - CounterAssetCode string `json:"counterAssetCode"` - Amount float64 `json:"amount"` - Scale float64 `json:"scale"` - Source string `json:"source"` + BaseAssetCode string `json:"baseAssetCode" example:"BRL"` + CounterAssetCode string `json:"counterAssetCode" example:"USD"` + Amount float64 `json:"amount" example:"5000"` + Scale float64 `json:"scale" example:"2"` + Source string `json:"source" example:"@person1"` Metadata map[string]any `json:"metadata,omitempty"` -} +} // @name CreateAssetRateInput // AssetRate is a struct designed to encapsulate response payload data. +// +// swagger:model AssetRate + type AssetRate struct { - ID string `json:"id"` - BaseAssetCode string `json:"baseAssetCode"` - CounterAssetCode string `json:"counterAssetCode"` - Amount float64 `json:"amount"` - Scale float64 `json:"scale"` - Source string `json:"source"` - OrganizationID string `json:"organizationId"` - LedgerID string `json:"ledgerId"` - CreatedAt time.Time `json:"createdAt"` + ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"` + BaseAssetCode string `json:"baseAssetCode" example:"BRL"` + CounterAssetCode string `json:"counterAssetCode" example:"USD"` + Amount float64 `json:"amount" example:"5000"` + Scale float64 `json:"scale" example:"2"` + Source string `json:"source" example:"@person1"` + OrganizationID string `json:"organizationId" example:"00000000-0000-0000-0000-000000000000"` + LedgerID string `json:"ledgerId" example:"00000000-0000-0000-0000-000000000000"` + CreatedAt time.Time `json:"createdAt" example:"2021-01-01T00:00:00Z"` Metadata map[string]any `json:"metadata"` -} +} // @name AssetRate // ToEntity converts an TransactionPostgreSQLModel to entity Transaction func (a *AssetRatePostgreSQLModel) ToEntity() *AssetRate { diff --git a/components/transaction/internal/domain/operation/operation.go b/components/transaction/internal/domain/operation/operation.go index e55de283..84159530 100644 --- a/components/transaction/internal/domain/operation/operation.go +++ b/components/transaction/internal/domain/operation/operation.go @@ -36,10 +36,13 @@ type OperationPostgreSQLModel struct { } // Status structure for marshaling/unmarshalling JSON. +// +// swagger:model Status +// @Description Status structure for marshaling/unmarshalling JSON. type Status struct { - Code string `json:"code" validate:"max=100"` - Description *string `json:"description" validate:"omitempty,max=256"` -} + Code string `json:"code" validate:"max=100" example:"ACTIVE"` + Description *string `json:"description" validate:"omitempty,max=256" example:"Active status"` +} // @name Status // IsEmpty method that set empty or nil in fields func (s Status) IsEmpty() bool { @@ -47,10 +50,13 @@ func (s Status) IsEmpty() bool { } // Amount structure for marshaling/unmarshalling JSON. +// +// swagger:model Amount +// @Description Amount structure for marshaling/unmarshalling JSON. type Amount struct { - Amount *float64 `json:"amount"` - Scale *float64 `json:"scale"` -} + Amount *float64 `json:"amount" example:"1500"` + Scale *float64 `json:"scale" example:"2"` +} // @name Amount // IsEmpty method that set empty or nil in fields func (a Amount) IsEmpty() bool { @@ -58,11 +64,14 @@ func (a Amount) IsEmpty() bool { } // Balance structure for marshaling/unmarshalling JSON. +// +// swagger:model Balance +// @Description Balance structure for marshaling/unmarshalling JSON. type Balance struct { - Available *float64 `json:"available"` - OnHold *float64 `json:"onHold"` - Scale *float64 `json:"scale"` -} + Available *float64 `json:"available" example:"1500"` + OnHold *float64 `json:"onHold" example:"500"` + Scale *float64 `json:"scale" example:"2"` +} // @name Balance // IsEmpty method that set empty or nil in fields func (b Balance) IsEmpty() bool { @@ -70,27 +79,30 @@ func (b Balance) IsEmpty() bool { } // Operation is a struct designed to encapsulate response payload data. +// +// swagger:model Operation +// @Description Operation is a struct designed to encapsulate response payload data. type Operation struct { - ID string `json:"id"` - TransactionID string `json:"transactionId"` - Description string `json:"description"` - Type string `json:"type"` - AssetCode string `json:"assetCode"` - ChartOfAccounts string `json:"chartOfAccounts"` + ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"` + TransactionID string `json:"transactionId" example:"00000000-0000-0000-0000-000000000000"` + Description string `json:"description" example:"Credit card operation"` + Type string `json:"type" example:"creditCard"` + AssetCode string `json:"assetCode" example:"BRL"` + ChartOfAccounts string `json:"chartOfAccounts" example:"1000"` Amount Amount `json:"amount"` Balance Balance `json:"balance"` BalanceAfter Balance `json:"balanceAfter"` Status Status `json:"status"` - AccountID string `json:"accountId"` - AccountAlias string `json:"accountAlias"` - PortfolioID *string `json:"portfolioId"` - OrganizationID string `json:"organizationId"` - LedgerID string `json:"ledgerId"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - DeletedAt *time.Time `json:"deletedAt"` - Metadata map[string]any `json:"metadata"` -} + AccountID string `json:"accountId" example:"00000000-0000-0000-0000-000000000000"` + AccountAlias string `json:"accountAlias" example:"@person1"` + PortfolioID *string `json:"portfolioId" example:"00000000-0000-0000-0000-000000000000"` + OrganizationID string `json:"organizationId" example:"00000000-0000-0000-0000-000000000000"` + LedgerID string `json:"ledgerId" example:"00000000-0000-0000-0000-000000000000"` + CreatedAt time.Time `json:"createdAt" example:"2021-01-01T00:00:00Z"` + UpdatedAt time.Time `json:"updatedAt" example:"2021-01-01T00:00:00Z"` + DeletedAt *time.Time `json:"deletedAt" example:"2021-01-01T00:00:00Z"` + Metadata map[string]any `json:"metadata" example:map[string]any{"key": "value"}` +} // @name Operation // ToEntity converts an OperationPostgreSQLModel to entity Operation func (t *OperationPostgreSQLModel) ToEntity() *Operation { @@ -184,7 +196,10 @@ func (t *OperationPostgreSQLModel) FromEntity(operation *Operation) { } // UpdateOperationInput is a struct design to encapsulate payload data. +// +// swagger:model UpdateOperationInput +// @Description UpdateOperationInput is a struct design to encapsulate payload data. type UpdateOperationInput struct { - Description string `json:"description" validate:"max=256"` + Description string `json:"description" validate:"max=256" example:"Credit card operation"` Metadata map[string]any `json:"metadata,omitempty"` -} +} // @name UpdateOperationInput diff --git a/components/transaction/internal/domain/transaction/transaction.go b/components/transaction/internal/domain/transaction/transaction.go index 66456d58..7eb34019 100644 --- a/components/transaction/internal/domain/transaction/transaction.go +++ b/components/transaction/internal/domain/transaction/transaction.go @@ -31,10 +31,13 @@ type TransactionPostgreSQLModel struct { } // Status structure for marshaling/unmarshalling JSON. +// +// swagger:model Status +// @Description Status structure for marshaling/unmarshalling JSON. type Status struct { - Code string `json:"code" validate:"max=100"` - Description *string `json:"description" validate:"omitempty,max=256"` -} + Code string `json:"code" validate:"max=100" example:"ACTIVE"` + Description *string `json:"description" validate:"omitempty,max=256" example:"Active status"` +} // @name Status // IsEmpty method that set empty or nil in fields func (s Status) IsEmpty() bool { @@ -50,7 +53,7 @@ type CreateTransactionInput struct { Metadata map[string]any `json:"metadata,omitempty"` Send *gold.Send `json:"send,omitempty" validate:"required,dive"` Distribute *gold.Distribute `json:"distribute,omitempty" validate:"required,dive"` -} +} // @name CreateTransactionInput // InputDSL is a struct design to encapsulate payload data. type InputDSL struct { @@ -60,32 +63,38 @@ type InputDSL struct { } // UpdateTransactionInput is a struct design to encapsulate payload data. +// +// swagger:model UpdateTransactionInput +// @Description UpdateTransactionInput is a struct design to encapsulate payload data. type UpdateTransactionInput struct { - Description string `json:"description" validate:"max=256"` + Description string `json:"description" validate:"max=256" example:"Transaction description"` Metadata map[string]any `json:"metadata,omitempty"` -} +} // @name UpdateTransactionInput // Transaction is a struct designed to encapsulate response payload data. +// +// swagger:model Transaction +// @Description Transaction is a struct designed to encapsulate response payload data. type Transaction struct { - ID string `json:"id"` - ParentTransactionID *string `json:"parentTransactionId,omitempty"` - Description string `json:"description"` - Template string `json:"template"` + ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"` + ParentTransactionID *string `json:"parentTransactionId,omitempty" example:"00000000-0000-0000-0000-000000000000"` + Description string `json:"description" example:"Transaction description"` + Template string `json:"template" example:"Transaction template"` Status Status `json:"status"` - Amount *float64 `json:"amount"` - AmountScale *float64 `json:"amountScale"` - AssetCode string `json:"assetCode"` - ChartOfAccountsGroupName string `json:"chartOfAccountsGroupName"` - Source []string `json:"source"` - Destination []string `json:"destination"` - LedgerID string `json:"ledgerId"` - OrganizationID string `json:"organizationId"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - DeletedAt *time.Time `json:"deletedAt"` + Amount *float64 `json:"amount" example:"1500"` + AmountScale *float64 `json:"amountScale" example:"2"` + AssetCode string `json:"assetCode" example:"BRL"` + ChartOfAccountsGroupName string `json:"chartOfAccountsGroupName" example:"Chart of accounts group name"` + Source []string `json:"source" example:"@person1"` + Destination []string `json:"destination" example:"@person2"` + LedgerID string `json:"ledgerId" example:"00000000-0000-0000-0000-000000000000"` + OrganizationID string `json:"organizationId" example:"00000000-0000-0000-0000-000000000000"` + CreatedAt time.Time `json:"createdAt" example:"2021-01-01T00:00:00Z"` + UpdatedAt time.Time `json:"updatedAt" example:"2021-01-01T00:00:00Z"` + DeletedAt *time.Time `json:"deletedAt" example:"2021-01-01T00:00:00Z"` Metadata map[string]any `json:"metadata,omitempty"` Operations []*o.Operation `json:"operations"` -} +} // @name Transaction // ToEntity converts an TransactionPostgreSQLModel to entity Transaction func (t *TransactionPostgreSQLModel) ToEntity() *Transaction { diff --git a/components/transaction/internal/main.go b/components/transaction/internal/main.go index b55b77e5..3b8ec13c 100644 --- a/components/transaction/internal/main.go +++ b/components/transaction/internal/main.go @@ -5,16 +5,16 @@ import ( "github.com/LerianStudio/midaz/components/transaction/internal/gen" ) -// @title Midaz Transaction API -// @version 1.0 -// @description This is a swagger documentation for the Midaz Transaction API -// @termsOfService http://swagger.io/terms/ -// @contact.name Discord community -// @contact.url https://discord.gg/DnhqKwkGv3 -// @license.name Apache 2.0 -// @license.url http://www.apache.org/licenses/LICENSE-2.0.html -// @host localhost:3002 -// @BasePath / +// @title Midaz Transaction API +// @version 1.0 +// @description This is a swagger documentation for the Midaz Transaction API +// @termsOfService http://swagger.io/terms/ +// @contact.name Discord community +// @contact.url https://discord.gg/DnhqKwkGv3 +// @license.name Apache 2.0 +// @license.url http://www.apache.org/licenses/LICENSE-2.0.html +// @host localhost:3002 +// @BasePath / func main() { common.InitLocalEnvConfig() gen.InitializeService().Run() diff --git a/components/transaction/internal/ports/http/assetrate.go b/components/transaction/internal/ports/http/assetrate.go index 49b5de8e..244599b3 100644 --- a/components/transaction/internal/ports/http/assetrate.go +++ b/components/transaction/internal/ports/http/assetrate.go @@ -18,6 +18,20 @@ type AssetRateHandler struct { } // CreateAssetRate creates a new asset rate. +// +// @Summary Create an AssetRate +// @Description Create an AssetRate with the input payload +// @Tags Asset Rates +// @Accept json +// @Produce json +// +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// +// @Param asset-rate body ar.CreateAssetRateInput true "AssetRate Input" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} ar.AssetRate +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/asset-rates [post] func (handler *AssetRateHandler) CreateAssetRate(p any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -58,6 +72,20 @@ func (handler *AssetRateHandler) CreateAssetRate(p any, c *fiber.Ctx) error { } // GetAssetRate retrieves an asset rate. +// +// @Summary Get an AssetRate by ID +// @Description Get an AssetRate with the input ID +// @Tags Asset Rates +// @Produce json +// +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param asset_rate_id path string true "AssetRate ID" +// +// @Param asset-rate body ar.CreateAssetRateInput true "AssetRate Input" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} ar.AssetRate +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/asset-rates/{asset_rate_id} [get] func (handler *AssetRateHandler) GetAssetRate(c *fiber.Ctx) error { ctx := c.UserContext() diff --git a/components/transaction/internal/ports/http/operation.go b/components/transaction/internal/ports/http/operation.go index 76dc1a4a..6ed96ef4 100644 --- a/components/transaction/internal/ports/http/operation.go +++ b/components/transaction/internal/ports/http/operation.go @@ -20,6 +20,19 @@ type OperationHandler struct { } // GetAllOperationsByAccount retrieves all operations by account. +// +// @Summary Get all Operations by account +// @Description Get all Operations with the input ID +// @Tags Operations +// @Produce json +// +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// +// @Param account_id path string true "Account ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mpostgres.Pagination{items=[]o.Operation} +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{account_id}/operations [get] func (handler *OperationHandler) GetAllOperationsByAccount(c *fiber.Ctx) error { ctx := c.UserContext() @@ -67,6 +80,21 @@ func (handler *OperationHandler) GetAllOperationsByAccount(c *fiber.Ctx) error { return commonHTTP.OK(c, pagination) } +// GetOperationByAccount retrieves an operation by account. +// +// @Summary Get an Operation by account +// @Description Get an Operation with the input ID +// @Tags Operations +// @Produce json +// +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// +// @Param account_id path string true "Account ID" +// @Param operation_id path string true "Operation ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} o.Operation +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{account_id}/operations/{operation_id} [get] func (handler *OperationHandler) GetOperationByAccount(c *fiber.Ctx) error { ctx := c.UserContext() @@ -97,6 +125,20 @@ func (handler *OperationHandler) GetOperationByAccount(c *fiber.Ctx) error { return commonHTTP.OK(c, operation) } +// GetAllOperationsByPortfolio retrieves all operations by portfolio. +// +// @Summary Get all Operations by portfolio +// @Description Get all Operations with the input ID +// @Tags Operations +// @Produce json +// +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// +// @Param portfolio_id path string true "Portfolio ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mpostgres.Pagination{items=[]o.Operation} +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/operations [get] func (handler *OperationHandler) GetAllOperationsByPortfolio(c *fiber.Ctx) error { ctx := c.UserContext() @@ -144,6 +186,21 @@ func (handler *OperationHandler) GetAllOperationsByPortfolio(c *fiber.Ctx) error return commonHTTP.OK(c, pagination) } +// GetOperationByPortfolio retrieves an operation by portfolio. +// +// @Summary Get an Operation by portfolio +// @Description Get an Operation with the input ID +// @Tags Operations +// @Produce json +// +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// +// @Param portfolio_id path string true "Portfolio ID" +// @Param operation_id path string true "Operation ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} o.Operation +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/operations/{operation_id} [get] func (handler *OperationHandler) GetOperationByPortfolio(c *fiber.Ctx) error { ctx := c.UserContext() @@ -175,6 +232,22 @@ func (handler *OperationHandler) GetOperationByPortfolio(c *fiber.Ctx) error { } // UpdateOperation method that patch operation created before +// +// @Summary Update an Operation +// @Description Update an Operation with the input payload +// @Tags Operations +// @Accept json +// @Produce json +// +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param transaction_id path string true "Transaction ID" +// @Param operation_id path string true "Operation ID" +// +// @Param operation body o.UpdateOperationInput true "Operation Input" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} o.Operation +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/{transaction_id}/operations/{operation_id} [patch] func (handler *OperationHandler) UpdateOperation(p any, c *fiber.Ctx) error { ctx := c.UserContext() diff --git a/components/transaction/internal/ports/http/routes.go b/components/transaction/internal/ports/http/routes.go index 5c9ddcbb..3483fa1b 100644 --- a/components/transaction/internal/ports/http/routes.go +++ b/components/transaction/internal/ports/http/routes.go @@ -59,8 +59,7 @@ func NewRouter(lg mlog.Logger, tl *mopentelemetry.Telemetry, cc *mcasdoor.Casdoo f.Get("/version", lib.Version) // Doc - f.Get("/swagger/*", lib.WithSwaggerEnvConfig(), fiberSwagger.WrapHandler) - lib.DocAPI("transaction", "Transaction API", f) + f.Get("/swagger/*", WithSwaggerEnvConfig(), fiberSwagger.WrapHandler) f.Use(tlMid.EndTracingSpans) diff --git a/components/transaction/internal/ports/http/swagger.go b/components/transaction/internal/ports/http/swagger.go new file mode 100644 index 00000000..6c18bedc --- /dev/null +++ b/components/transaction/internal/ports/http/swagger.go @@ -0,0 +1,34 @@ +package http + +import ( + "github.com/LerianStudio/midaz/components/transaction/api" + "github.com/gofiber/fiber/v2" + "os" +) + +// WithSwaggerEnvConfig sets the Swagger configuration for the API documentation from environment variables if they are set. +func WithSwaggerEnvConfig() fiber.Handler { + return func(c *fiber.Ctx) error { + envVars := map[string]*string{ + "SWAGGER_TITLE": &api.SwaggerInfo.Title, + "SWAGGER_DESCRIPTION": &api.SwaggerInfo.Description, + "SWAGGER_VERSION": &api.SwaggerInfo.Version, + "SWAGGER_HOST": &api.SwaggerInfo.Host, + "SWAGGER_BASE_PATH": &api.SwaggerInfo.BasePath, + "SWAGGER_LEFT_DELIM": &api.SwaggerInfo.LeftDelim, + "SWAGGER_RIGHT_DELIM": &api.SwaggerInfo.RightDelim, + } + + for env, field := range envVars { + if value := os.Getenv(env); value != "" { + *field = value + } + } + + if schemes := os.Getenv("SWAGGER_SCHEMES"); schemes != "" { + api.SwaggerInfo.Schemes = []string{schemes} + } + + return c.Next() + } +} diff --git a/components/transaction/internal/ports/http/transaction.go b/components/transaction/internal/ports/http/transaction.go index 4fc96ff8..48f93fea 100644 --- a/components/transaction/internal/ports/http/transaction.go +++ b/components/transaction/internal/ports/http/transaction.go @@ -31,6 +31,20 @@ type TransactionHandler struct { } // CreateTransactionJSON method that create transaction using JSON +// +// @Summary Create a Transaction using JSON +// @Description Create a Transaction with the input payload +// @Tags Transactions +// @Accept json +// @Produce json +// +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// +// @Param transaction body t.CreateTransactionInput true "Transaction Input" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} t.Transaction +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/json [post] func (handler *TransactionHandler) CreateTransactionJSON(p any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -52,6 +66,20 @@ func (handler *TransactionHandler) CreateTransactionJSON(p any, c *fiber.Ctx) er } // CreateTransactionDSL method that create transaction using DSL +// +// @Summary Create a Transaction using DSL +// @Description Create a Transaction with the input DSL file +// @Tags Transactions +// @Accept mpfd +// @Produce json +// +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// +// @Param transaction formData file true "Transaction DSL file" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} t.Transaction +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/dsl [post] func (handler *TransactionHandler) CreateTransactionDSL(c *fiber.Ctx) error { ctx := c.UserContext() @@ -100,6 +128,8 @@ func (handler *TransactionHandler) CreateTransactionDSL(c *fiber.Ctx) error { } // CreateTransactionTemplate method that create transaction template +// +// TODO: Implement this method and the swagger documentation related to it func (handler *TransactionHandler) CreateTransactionTemplate(p any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -115,6 +145,8 @@ func (handler *TransactionHandler) CreateTransactionTemplate(p any, c *fiber.Ctx } // CommitTransaction method that commit transaction created before +// +// TODO: Implement this method and the swagger documentation related to it func (handler *TransactionHandler) CommitTransaction(c *fiber.Ctx) error { ctx := c.UserContext() @@ -128,6 +160,8 @@ func (handler *TransactionHandler) CommitTransaction(c *fiber.Ctx) error { } // RevertTransaction method that revert transaction created before +// +// TODO: Implement this method and the swagger documentation related to it func (handler *TransactionHandler) RevertTransaction(c *fiber.Ctx) error { ctx := c.UserContext() @@ -141,6 +175,21 @@ func (handler *TransactionHandler) RevertTransaction(c *fiber.Ctx) error { } // UpdateTransaction method that patch transaction created before +// +// @Summary Update a Transaction +// @Description Update a Transaction with the input payload +// @Tags Transactions +// @Accept json +// @Produce json +// +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param transaction_id path string true "Transaction ID" +// +// @Param transaction body t.UpdateTransactionInput true "Transaction Input" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} t.Transaction +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/{transaction_id} [patch] func (handler *TransactionHandler) UpdateTransaction(p any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -183,6 +232,19 @@ func (handler *TransactionHandler) UpdateTransaction(p any, c *fiber.Ctx) error } // GetTransaction method that get transaction created before +// +// @Summary Get a Transaction by ID +// @Description Get a Transaction with the input ID +// @Tags Transactions +// @Produce json +// +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param transaction_id path string true "Transaction ID" +// +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} t.Transaction +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/{transaction_id} [get] func (handler *TransactionHandler) GetTransaction(c *fiber.Ctx) error { ctx := c.UserContext() @@ -210,6 +272,19 @@ func (handler *TransactionHandler) GetTransaction(c *fiber.Ctx) error { return commonHTTP.OK(c, tran) } +// GetAllTransactions method that get all transactions created before +// +// @Summary Get all Transactions +// @Description Get all Transactions with the input metadata or without metadata +// @Tags Transactions +// @Produce json +// +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mpostgres.Pagination{items=[]t.Transaction} +// @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions [get] func (handler *TransactionHandler) GetAllTransactions(c *fiber.Ctx) error { ctx := c.UserContext() From a6e377576673c4a2c0a2691f717518d9ade65e0f Mon Sep 17 00:00:00 2001 From: Brecci Date: Mon, 25 Nov 2024 15:41:23 -0300 Subject: [PATCH 3/4] feat: add swagger generated docs from transaction :sparkles: --- components/transaction/api/docs.go | 1230 +++++++++++++++++++++++ components/transaction/api/swagger.json | 1206 ++++++++++++++++++++++ components/transaction/api/swagger.yaml | 825 +++++++++++++++ 3 files changed, 3261 insertions(+) create mode 100644 components/transaction/api/docs.go create mode 100644 components/transaction/api/swagger.json create mode 100644 components/transaction/api/swagger.yaml diff --git a/components/transaction/api/docs.go b/components/transaction/api/docs.go new file mode 100644 index 00000000..52409451 --- /dev/null +++ b/components/transaction/api/docs.go @@ -0,0 +1,1230 @@ +// Package api Code generated by swaggo/swag. DO NOT EDIT +package api + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "name": "Discord community", + "url": "https://discord.gg/DnhqKwkGv3" + }, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{account_id}/operations": { + "get": { + "description": "Get all Operations with the input ID", + "produces": [ + "application/json" + ], + "tags": [ + "Operations" + ], + "summary": "Get all Operations by account", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Account ID", + "name": "account_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/Pagination" + }, + { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/Operation" + } + } + } + } + ] + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{account_id}/operations/{operation_id}": { + "get": { + "description": "Get an Operation with the input ID", + "produces": [ + "application/json" + ], + "tags": [ + "Operations" + ], + "summary": "Get an Operation by account", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Account ID", + "name": "account_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Operation ID", + "name": "operation_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Operation" + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/asset-rates": { + "post": { + "description": "Create an AssetRate with the input payload", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Asset Rates" + ], + "summary": "Create an AssetRate", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "description": "AssetRate Input", + "name": "asset-rate", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateAssetRateInput" + } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/AssetRate" + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/asset-rates/{asset_rate_id}": { + "get": { + "description": "Get an AssetRate with the input ID", + "produces": [ + "application/json" + ], + "tags": [ + "Asset Rates" + ], + "summary": "Get an AssetRate by ID", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "AssetRate ID", + "name": "asset_rate_id", + "in": "path", + "required": true + }, + { + "description": "AssetRate Input", + "name": "asset-rate", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateAssetRateInput" + } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/AssetRate" + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/operations": { + "get": { + "description": "Get all Operations with the input ID", + "produces": [ + "application/json" + ], + "tags": [ + "Operations" + ], + "summary": "Get all Operations by portfolio", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Portfolio ID", + "name": "portfolio_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/Pagination" + }, + { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/Operation" + } + } + } + } + ] + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/operations/{operation_id}": { + "get": { + "description": "Get an Operation with the input ID", + "produces": [ + "application/json" + ], + "tags": [ + "Operations" + ], + "summary": "Get an Operation by portfolio", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Portfolio ID", + "name": "portfolio_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Operation ID", + "name": "operation_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Operation" + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions": { + "get": { + "description": "Get all Transactions with the input metadata or without metadata", + "produces": [ + "application/json" + ], + "tags": [ + "Transactions" + ], + "summary": "Get all Transactions", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/Pagination" + }, + { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/Transaction" + } + } + } + } + ] + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/dsl": { + "post": { + "description": "Create a Transaction with the input DSL file", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Transactions" + ], + "summary": "Create a Transaction using DSL", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "file", + "description": "Transaction DSL file", + "name": "transaction", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Transaction" + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/json": { + "post": { + "description": "Create a Transaction with the input payload", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Transactions" + ], + "summary": "Create a Transaction using JSON", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "description": "Transaction Input", + "name": "transaction", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateTransactionInput" + } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Transaction" + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/{transaction_id}": { + "get": { + "description": "Get a Transaction with the input ID", + "produces": [ + "application/json" + ], + "tags": [ + "Transactions" + ], + "summary": "Get a Transaction by ID", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Transaction ID", + "name": "transaction_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Transaction" + } + } + } + }, + "patch": { + "description": "Update a Transaction with the input payload", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Transactions" + ], + "summary": "Update a Transaction", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Transaction ID", + "name": "transaction_id", + "in": "path", + "required": true + }, + { + "description": "Transaction Input", + "name": "transaction", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UpdateTransactionInput" + } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Transaction" + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/{transaction_id}/operations/{operation_id}": { + "patch": { + "description": "Update an Operation with the input payload", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Operations" + ], + "summary": "Update an Operation", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Transaction ID", + "name": "transaction_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Operation ID", + "name": "operation_id", + "in": "path", + "required": true + }, + { + "description": "Operation Input", + "name": "operation", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UpdateOperationInput" + } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Operation" + } + } + } + } + } + }, + "definitions": { + "Amount": { + "description": "Amount structure for marshaling/unmarshalling JSON.", + "type": "object", + "properties": { + "amount": { + "type": "number", + "example": 1500 + }, + "scale": { + "type": "number", + "example": 2 + } + } + }, + "AssetRate": { + "type": "object", + "properties": { + "amount": { + "type": "number", + "example": 5000 + }, + "baseAssetCode": { + "type": "string", + "example": "BRL" + }, + "counterAssetCode": { + "type": "string", + "example": "USD" + }, + "createdAt": { + "type": "string", + "example": "2021-01-01T00:00:00Z" + }, + "id": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "ledgerId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + }, + "organizationId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "scale": { + "type": "number", + "example": 2 + }, + "source": { + "type": "string", + "example": "@person1" + } + } + }, + "Balance": { + "description": "Balance structure for marshaling/unmarshalling JSON.", + "type": "object", + "properties": { + "available": { + "type": "number", + "example": 1500 + }, + "onHold": { + "type": "number", + "example": 500 + }, + "scale": { + "type": "number", + "example": 2 + } + } + }, + "CreateAssetRateInput": { + "description": "CreateAssetRateInput is a struct design to encapsulate payload data.", + "type": "object", + "properties": { + "amount": { + "type": "number", + "example": 5000 + }, + "baseAssetCode": { + "type": "string", + "example": "BRL" + }, + "counterAssetCode": { + "type": "string", + "example": "USD" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + }, + "scale": { + "type": "number", + "example": 2 + }, + "source": { + "type": "string", + "example": "@person1" + } + } + }, + "CreateTransactionInput": { + "type": "object", + "required": [ + "distribute", + "send" + ], + "properties": { + "chartOfAccountsGroupName": { + "type": "string", + "maxLength": 256 + }, + "code": { + "type": "string", + "maxLength": 100 + }, + "description": { + "type": "string", + "maxLength": 256 + }, + "distribute": { + "$ref": "#/definitions/model.Distribute" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + }, + "pending": { + "type": "boolean" + }, + "send": { + "$ref": "#/definitions/model.Send" + } + } + }, + "Operation": { + "description": "Operation is a struct designed to encapsulate response payload data.", + "type": "object", + "properties": { + "accountAlias": { + "type": "string", + "example": "@person1" + }, + "accountId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "amount": { + "$ref": "#/definitions/Amount" + }, + "assetCode": { + "type": "string", + "example": "BRL" + }, + "balance": { + "$ref": "#/definitions/Balance" + }, + "balanceAfter": { + "$ref": "#/definitions/Balance" + }, + "chartOfAccounts": { + "type": "string", + "example": "1000" + }, + "createdAt": { + "type": "string", + "example": "2021-01-01T00:00:00Z" + }, + "deletedAt": { + "type": "string", + "example": "2021-01-01T00:00:00Z" + }, + "description": { + "type": "string", + "example": "Credit card operation" + }, + "id": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "ledgerId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + }, + "organizationId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "portfolioId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "status": { + "$ref": "#/definitions/Status" + }, + "transactionId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "type": { + "type": "string", + "example": "creditCard" + }, + "updatedAt": { + "type": "string", + "example": "2021-01-01T00:00:00Z" + } + } + }, + "Pagination": { + "description": "Pagination is a struct designed to encapsulate pagination response payload data.", + "type": "object", + "properties": { + "items": {}, + "limit": { + "type": "integer", + "example": 10 + }, + "page": { + "type": "integer", + "example": 1 + } + } + }, + "Status": { + "description": "Status structure for marshaling/unmarshalling JSON.", + "type": "object", + "properties": { + "code": { + "type": "string", + "maxLength": 100, + "example": "ACTIVE" + }, + "description": { + "type": "string", + "maxLength": 256, + "example": "Active status" + } + } + }, + "Transaction": { + "description": "Transaction is a struct designed to encapsulate response payload data.", + "type": "object", + "properties": { + "amount": { + "type": "number", + "example": 1500 + }, + "amountScale": { + "type": "number", + "example": 2 + }, + "assetCode": { + "type": "string", + "example": "BRL" + }, + "chartOfAccountsGroupName": { + "type": "string", + "example": "Chart of accounts group name" + }, + "createdAt": { + "type": "string", + "example": "2021-01-01T00:00:00Z" + }, + "deletedAt": { + "type": "string", + "example": "2021-01-01T00:00:00Z" + }, + "description": { + "type": "string", + "example": "Transaction description" + }, + "destination": { + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "@person2" + ] + }, + "id": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "ledgerId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + }, + "operations": { + "type": "array", + "items": { + "$ref": "#/definitions/Operation" + } + }, + "organizationId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "parentTransactionId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "source": { + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "@person1" + ] + }, + "status": { + "$ref": "#/definitions/Status" + }, + "template": { + "type": "string", + "example": "Transaction template" + }, + "updatedAt": { + "type": "string", + "example": "2021-01-01T00:00:00Z" + } + } + }, + "UpdateOperationInput": { + "description": "UpdateOperationInput is a struct design to encapsulate payload data.", + "type": "object", + "properties": { + "description": { + "type": "string", + "maxLength": 256, + "example": "Credit card operation" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + } + } + }, + "UpdateTransactionInput": { + "description": "UpdateTransactionInput is a struct design to encapsulate payload data.", + "type": "object", + "properties": { + "description": { + "type": "string", + "maxLength": 256, + "example": "Transaction description" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + } + } + }, + "model.Amount": { + "type": "object", + "required": [ + "asset", + "value" + ], + "properties": { + "asset": { + "type": "string" + }, + "scale": { + "type": "integer", + "minimum": 0 + }, + "value": { + "type": "integer" + } + } + }, + "model.Distribute": { + "type": "object", + "required": [ + "to" + ], + "properties": { + "remaining": { + "type": "string" + }, + "to": { + "type": "array", + "items": { + "$ref": "#/definitions/model.FromTo" + } + } + } + }, + "model.FromTo": { + "type": "object", + "properties": { + "account": { + "type": "string" + }, + "amount": { + "$ref": "#/definitions/model.Amount" + }, + "chartOfAccountsG": { + "type": "string" + }, + "description": { + "type": "string" + }, + "isFrom": { + "type": "boolean" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + }, + "remaining": { + "type": "string" + }, + "share": { + "$ref": "#/definitions/model.Share" + } + } + }, + "model.Send": { + "type": "object", + "required": [ + "asset", + "source", + "value" + ], + "properties": { + "asset": { + "type": "string" + }, + "scale": { + "type": "integer", + "minimum": 0 + }, + "source": { + "$ref": "#/definitions/model.Source" + }, + "value": { + "type": "integer" + } + } + }, + "model.Share": { + "type": "object", + "required": [ + "percentage" + ], + "properties": { + "descWhatever": { + "type": "boolean" + }, + "percentage": { + "type": "integer" + }, + "percentageOfPercentage": { + "type": "integer" + } + } + }, + "model.Source": { + "type": "object", + "required": [ + "from" + ], + "properties": { + "from": { + "type": "array", + "items": { + "$ref": "#/definitions/model.FromTo" + } + }, + "remaining": { + "type": "string" + } + } + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1.0", + Host: "localhost:3002", + BasePath: "/", + Schemes: []string{}, + Title: "Midaz Transaction API", + Description: "This is a swagger documentation for the Midaz Transaction API", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/components/transaction/api/swagger.json b/components/transaction/api/swagger.json new file mode 100644 index 00000000..4d60d1d8 --- /dev/null +++ b/components/transaction/api/swagger.json @@ -0,0 +1,1206 @@ +{ + "swagger": "2.0", + "info": { + "description": "This is a swagger documentation for the Midaz Transaction API", + "title": "Midaz Transaction API", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "name": "Discord community", + "url": "https://discord.gg/DnhqKwkGv3" + }, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version": "1.0" + }, + "host": "localhost:3002", + "basePath": "/", + "paths": { + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{account_id}/operations": { + "get": { + "description": "Get all Operations with the input ID", + "produces": [ + "application/json" + ], + "tags": [ + "Operations" + ], + "summary": "Get all Operations by account", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Account ID", + "name": "account_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/Pagination" + }, + { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/Operation" + } + } + } + } + ] + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{account_id}/operations/{operation_id}": { + "get": { + "description": "Get an Operation with the input ID", + "produces": [ + "application/json" + ], + "tags": [ + "Operations" + ], + "summary": "Get an Operation by account", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Account ID", + "name": "account_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Operation ID", + "name": "operation_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Operation" + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/asset-rates": { + "post": { + "description": "Create an AssetRate with the input payload", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Asset Rates" + ], + "summary": "Create an AssetRate", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "description": "AssetRate Input", + "name": "asset-rate", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateAssetRateInput" + } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/AssetRate" + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/asset-rates/{asset_rate_id}": { + "get": { + "description": "Get an AssetRate with the input ID", + "produces": [ + "application/json" + ], + "tags": [ + "Asset Rates" + ], + "summary": "Get an AssetRate by ID", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "AssetRate ID", + "name": "asset_rate_id", + "in": "path", + "required": true + }, + { + "description": "AssetRate Input", + "name": "asset-rate", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateAssetRateInput" + } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/AssetRate" + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/operations": { + "get": { + "description": "Get all Operations with the input ID", + "produces": [ + "application/json" + ], + "tags": [ + "Operations" + ], + "summary": "Get all Operations by portfolio", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Portfolio ID", + "name": "portfolio_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/Pagination" + }, + { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/Operation" + } + } + } + } + ] + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/operations/{operation_id}": { + "get": { + "description": "Get an Operation with the input ID", + "produces": [ + "application/json" + ], + "tags": [ + "Operations" + ], + "summary": "Get an Operation by portfolio", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Portfolio ID", + "name": "portfolio_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Operation ID", + "name": "operation_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Operation" + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions": { + "get": { + "description": "Get all Transactions with the input metadata or without metadata", + "produces": [ + "application/json" + ], + "tags": [ + "Transactions" + ], + "summary": "Get all Transactions", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/Pagination" + }, + { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/Transaction" + } + } + } + } + ] + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/dsl": { + "post": { + "description": "Create a Transaction with the input DSL file", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Transactions" + ], + "summary": "Create a Transaction using DSL", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "file", + "description": "Transaction DSL file", + "name": "transaction", + "in": "formData", + "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Transaction" + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/json": { + "post": { + "description": "Create a Transaction with the input payload", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Transactions" + ], + "summary": "Create a Transaction using JSON", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "description": "Transaction Input", + "name": "transaction", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateTransactionInput" + } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Transaction" + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/{transaction_id}": { + "get": { + "description": "Get a Transaction with the input ID", + "produces": [ + "application/json" + ], + "tags": [ + "Transactions" + ], + "summary": "Get a Transaction by ID", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Transaction ID", + "name": "transaction_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Transaction" + } + } + } + }, + "patch": { + "description": "Update a Transaction with the input payload", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Transactions" + ], + "summary": "Update a Transaction", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Transaction ID", + "name": "transaction_id", + "in": "path", + "required": true + }, + { + "description": "Transaction Input", + "name": "transaction", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UpdateTransactionInput" + } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Transaction" + } + } + } + } + }, + "/v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/{transaction_id}/operations/{operation_id}": { + "patch": { + "description": "Update an Operation with the input payload", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Operations" + ], + "summary": "Update an Operation", + "parameters": [ + { + "type": "string", + "description": "Organization ID", + "name": "organization_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Ledger ID", + "name": "ledger_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Transaction ID", + "name": "transaction_id", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Operation ID", + "name": "operation_id", + "in": "path", + "required": true + }, + { + "description": "Operation Input", + "name": "operation", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UpdateOperationInput" + } + }, + { + "type": "string", + "description": "Request ID", + "name": "Midaz-Id", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Operation" + } + } + } + } + } + }, + "definitions": { + "Amount": { + "description": "Amount structure for marshaling/unmarshalling JSON.", + "type": "object", + "properties": { + "amount": { + "type": "number", + "example": 1500 + }, + "scale": { + "type": "number", + "example": 2 + } + } + }, + "AssetRate": { + "type": "object", + "properties": { + "amount": { + "type": "number", + "example": 5000 + }, + "baseAssetCode": { + "type": "string", + "example": "BRL" + }, + "counterAssetCode": { + "type": "string", + "example": "USD" + }, + "createdAt": { + "type": "string", + "example": "2021-01-01T00:00:00Z" + }, + "id": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "ledgerId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + }, + "organizationId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "scale": { + "type": "number", + "example": 2 + }, + "source": { + "type": "string", + "example": "@person1" + } + } + }, + "Balance": { + "description": "Balance structure for marshaling/unmarshalling JSON.", + "type": "object", + "properties": { + "available": { + "type": "number", + "example": 1500 + }, + "onHold": { + "type": "number", + "example": 500 + }, + "scale": { + "type": "number", + "example": 2 + } + } + }, + "CreateAssetRateInput": { + "description": "CreateAssetRateInput is a struct design to encapsulate payload data.", + "type": "object", + "properties": { + "amount": { + "type": "number", + "example": 5000 + }, + "baseAssetCode": { + "type": "string", + "example": "BRL" + }, + "counterAssetCode": { + "type": "string", + "example": "USD" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + }, + "scale": { + "type": "number", + "example": 2 + }, + "source": { + "type": "string", + "example": "@person1" + } + } + }, + "CreateTransactionInput": { + "type": "object", + "required": [ + "distribute", + "send" + ], + "properties": { + "chartOfAccountsGroupName": { + "type": "string", + "maxLength": 256 + }, + "code": { + "type": "string", + "maxLength": 100 + }, + "description": { + "type": "string", + "maxLength": 256 + }, + "distribute": { + "$ref": "#/definitions/model.Distribute" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + }, + "pending": { + "type": "boolean" + }, + "send": { + "$ref": "#/definitions/model.Send" + } + } + }, + "Operation": { + "description": "Operation is a struct designed to encapsulate response payload data.", + "type": "object", + "properties": { + "accountAlias": { + "type": "string", + "example": "@person1" + }, + "accountId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "amount": { + "$ref": "#/definitions/Amount" + }, + "assetCode": { + "type": "string", + "example": "BRL" + }, + "balance": { + "$ref": "#/definitions/Balance" + }, + "balanceAfter": { + "$ref": "#/definitions/Balance" + }, + "chartOfAccounts": { + "type": "string", + "example": "1000" + }, + "createdAt": { + "type": "string", + "example": "2021-01-01T00:00:00Z" + }, + "deletedAt": { + "type": "string", + "example": "2021-01-01T00:00:00Z" + }, + "description": { + "type": "string", + "example": "Credit card operation" + }, + "id": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "ledgerId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + }, + "organizationId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "portfolioId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "status": { + "$ref": "#/definitions/Status" + }, + "transactionId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "type": { + "type": "string", + "example": "creditCard" + }, + "updatedAt": { + "type": "string", + "example": "2021-01-01T00:00:00Z" + } + } + }, + "Pagination": { + "description": "Pagination is a struct designed to encapsulate pagination response payload data.", + "type": "object", + "properties": { + "items": {}, + "limit": { + "type": "integer", + "example": 10 + }, + "page": { + "type": "integer", + "example": 1 + } + } + }, + "Status": { + "description": "Status structure for marshaling/unmarshalling JSON.", + "type": "object", + "properties": { + "code": { + "type": "string", + "maxLength": 100, + "example": "ACTIVE" + }, + "description": { + "type": "string", + "maxLength": 256, + "example": "Active status" + } + } + }, + "Transaction": { + "description": "Transaction is a struct designed to encapsulate response payload data.", + "type": "object", + "properties": { + "amount": { + "type": "number", + "example": 1500 + }, + "amountScale": { + "type": "number", + "example": 2 + }, + "assetCode": { + "type": "string", + "example": "BRL" + }, + "chartOfAccountsGroupName": { + "type": "string", + "example": "Chart of accounts group name" + }, + "createdAt": { + "type": "string", + "example": "2021-01-01T00:00:00Z" + }, + "deletedAt": { + "type": "string", + "example": "2021-01-01T00:00:00Z" + }, + "description": { + "type": "string", + "example": "Transaction description" + }, + "destination": { + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "@person2" + ] + }, + "id": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "ledgerId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + }, + "operations": { + "type": "array", + "items": { + "$ref": "#/definitions/Operation" + } + }, + "organizationId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "parentTransactionId": { + "type": "string", + "example": "00000000-0000-0000-0000-000000000000" + }, + "source": { + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "@person1" + ] + }, + "status": { + "$ref": "#/definitions/Status" + }, + "template": { + "type": "string", + "example": "Transaction template" + }, + "updatedAt": { + "type": "string", + "example": "2021-01-01T00:00:00Z" + } + } + }, + "UpdateOperationInput": { + "description": "UpdateOperationInput is a struct design to encapsulate payload data.", + "type": "object", + "properties": { + "description": { + "type": "string", + "maxLength": 256, + "example": "Credit card operation" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + } + } + }, + "UpdateTransactionInput": { + "description": "UpdateTransactionInput is a struct design to encapsulate payload data.", + "type": "object", + "properties": { + "description": { + "type": "string", + "maxLength": 256, + "example": "Transaction description" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + } + } + }, + "model.Amount": { + "type": "object", + "required": [ + "asset", + "value" + ], + "properties": { + "asset": { + "type": "string" + }, + "scale": { + "type": "integer", + "minimum": 0 + }, + "value": { + "type": "integer" + } + } + }, + "model.Distribute": { + "type": "object", + "required": [ + "to" + ], + "properties": { + "remaining": { + "type": "string" + }, + "to": { + "type": "array", + "items": { + "$ref": "#/definitions/model.FromTo" + } + } + } + }, + "model.FromTo": { + "type": "object", + "properties": { + "account": { + "type": "string" + }, + "amount": { + "$ref": "#/definitions/model.Amount" + }, + "chartOfAccountsG": { + "type": "string" + }, + "description": { + "type": "string" + }, + "isFrom": { + "type": "boolean" + }, + "metadata": { + "type": "object", + "additionalProperties": {} + }, + "remaining": { + "type": "string" + }, + "share": { + "$ref": "#/definitions/model.Share" + } + } + }, + "model.Send": { + "type": "object", + "required": [ + "asset", + "source", + "value" + ], + "properties": { + "asset": { + "type": "string" + }, + "scale": { + "type": "integer", + "minimum": 0 + }, + "source": { + "$ref": "#/definitions/model.Source" + }, + "value": { + "type": "integer" + } + } + }, + "model.Share": { + "type": "object", + "required": [ + "percentage" + ], + "properties": { + "descWhatever": { + "type": "boolean" + }, + "percentage": { + "type": "integer" + }, + "percentageOfPercentage": { + "type": "integer" + } + } + }, + "model.Source": { + "type": "object", + "required": [ + "from" + ], + "properties": { + "from": { + "type": "array", + "items": { + "$ref": "#/definitions/model.FromTo" + } + }, + "remaining": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/components/transaction/api/swagger.yaml b/components/transaction/api/swagger.yaml new file mode 100644 index 00000000..fe73f40c --- /dev/null +++ b/components/transaction/api/swagger.yaml @@ -0,0 +1,825 @@ +basePath: / +definitions: + Amount: + description: Amount structure for marshaling/unmarshalling JSON. + properties: + amount: + example: 1500 + type: number + scale: + example: 2 + type: number + type: object + AssetRate: + properties: + amount: + example: 5000 + type: number + baseAssetCode: + example: BRL + type: string + counterAssetCode: + example: USD + type: string + createdAt: + example: "2021-01-01T00:00:00Z" + type: string + id: + example: 00000000-0000-0000-0000-000000000000 + type: string + ledgerId: + example: 00000000-0000-0000-0000-000000000000 + type: string + metadata: + additionalProperties: {} + type: object + organizationId: + example: 00000000-0000-0000-0000-000000000000 + type: string + scale: + example: 2 + type: number + source: + example: '@person1' + type: string + type: object + Balance: + description: Balance structure for marshaling/unmarshalling JSON. + properties: + available: + example: 1500 + type: number + onHold: + example: 500 + type: number + scale: + example: 2 + type: number + type: object + CreateAssetRateInput: + description: CreateAssetRateInput is a struct design to encapsulate payload data. + properties: + amount: + example: 5000 + type: number + baseAssetCode: + example: BRL + type: string + counterAssetCode: + example: USD + type: string + metadata: + additionalProperties: {} + type: object + scale: + example: 2 + type: number + source: + example: '@person1' + type: string + type: object + CreateTransactionInput: + properties: + chartOfAccountsGroupName: + maxLength: 256 + type: string + code: + maxLength: 100 + type: string + description: + maxLength: 256 + type: string + distribute: + $ref: '#/definitions/model.Distribute' + metadata: + additionalProperties: {} + type: object + pending: + type: boolean + send: + $ref: '#/definitions/model.Send' + required: + - distribute + - send + type: object + Operation: + description: Operation is a struct designed to encapsulate response payload data. + properties: + accountAlias: + example: '@person1' + type: string + accountId: + example: 00000000-0000-0000-0000-000000000000 + type: string + amount: + $ref: '#/definitions/Amount' + assetCode: + example: BRL + type: string + balance: + $ref: '#/definitions/Balance' + balanceAfter: + $ref: '#/definitions/Balance' + chartOfAccounts: + example: "1000" + type: string + createdAt: + example: "2021-01-01T00:00:00Z" + type: string + deletedAt: + example: "2021-01-01T00:00:00Z" + type: string + description: + example: Credit card operation + type: string + id: + example: 00000000-0000-0000-0000-000000000000 + type: string + ledgerId: + example: 00000000-0000-0000-0000-000000000000 + type: string + metadata: + additionalProperties: {} + type: object + organizationId: + example: 00000000-0000-0000-0000-000000000000 + type: string + portfolioId: + example: 00000000-0000-0000-0000-000000000000 + type: string + status: + $ref: '#/definitions/Status' + transactionId: + example: 00000000-0000-0000-0000-000000000000 + type: string + type: + example: creditCard + type: string + updatedAt: + example: "2021-01-01T00:00:00Z" + type: string + type: object + Pagination: + description: Pagination is a struct designed to encapsulate pagination response + payload data. + properties: + items: {} + limit: + example: 10 + type: integer + page: + example: 1 + type: integer + type: object + Status: + description: Status structure for marshaling/unmarshalling JSON. + properties: + code: + example: ACTIVE + maxLength: 100 + type: string + description: + example: Active status + maxLength: 256 + type: string + type: object + Transaction: + description: Transaction is a struct designed to encapsulate response payload + data. + properties: + amount: + example: 1500 + type: number + amountScale: + example: 2 + type: number + assetCode: + example: BRL + type: string + chartOfAccountsGroupName: + example: Chart of accounts group name + type: string + createdAt: + example: "2021-01-01T00:00:00Z" + type: string + deletedAt: + example: "2021-01-01T00:00:00Z" + type: string + description: + example: Transaction description + type: string + destination: + example: + - '@person2' + items: + type: string + type: array + id: + example: 00000000-0000-0000-0000-000000000000 + type: string + ledgerId: + example: 00000000-0000-0000-0000-000000000000 + type: string + metadata: + additionalProperties: {} + type: object + operations: + items: + $ref: '#/definitions/Operation' + type: array + organizationId: + example: 00000000-0000-0000-0000-000000000000 + type: string + parentTransactionId: + example: 00000000-0000-0000-0000-000000000000 + type: string + source: + example: + - '@person1' + items: + type: string + type: array + status: + $ref: '#/definitions/Status' + template: + example: Transaction template + type: string + updatedAt: + example: "2021-01-01T00:00:00Z" + type: string + type: object + UpdateOperationInput: + description: UpdateOperationInput is a struct design to encapsulate payload data. + properties: + description: + example: Credit card operation + maxLength: 256 + type: string + metadata: + additionalProperties: {} + type: object + type: object + UpdateTransactionInput: + description: UpdateTransactionInput is a struct design to encapsulate payload + data. + properties: + description: + example: Transaction description + maxLength: 256 + type: string + metadata: + additionalProperties: {} + type: object + type: object + model.Amount: + properties: + asset: + type: string + scale: + minimum: 0 + type: integer + value: + type: integer + required: + - asset + - value + type: object + model.Distribute: + properties: + remaining: + type: string + to: + items: + $ref: '#/definitions/model.FromTo' + type: array + required: + - to + type: object + model.FromTo: + properties: + account: + type: string + amount: + $ref: '#/definitions/model.Amount' + chartOfAccountsG: + type: string + description: + type: string + isFrom: + type: boolean + metadata: + additionalProperties: {} + type: object + remaining: + type: string + share: + $ref: '#/definitions/model.Share' + type: object + model.Send: + properties: + asset: + type: string + scale: + minimum: 0 + type: integer + source: + $ref: '#/definitions/model.Source' + value: + type: integer + required: + - asset + - source + - value + type: object + model.Share: + properties: + descWhatever: + type: boolean + percentage: + type: integer + percentageOfPercentage: + type: integer + required: + - percentage + type: object + model.Source: + properties: + from: + items: + $ref: '#/definitions/model.FromTo' + type: array + remaining: + type: string + required: + - from + type: object +host: localhost:3002 +info: + contact: + name: Discord community + url: https://discord.gg/DnhqKwkGv3 + description: This is a swagger documentation for the Midaz Transaction API + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + termsOfService: http://swagger.io/terms/ + title: Midaz Transaction API + version: "1.0" +paths: + /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{account_id}/operations: + get: + description: Get all Operations with the input ID + parameters: + - description: Organization ID + in: path + name: organization_id + required: true + type: string + - description: Ledger ID + in: path + name: ledger_id + required: true + type: string + - description: Account ID + in: path + name: account_id + required: true + type: string + - description: Request ID + in: header + name: Midaz-Id + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/Pagination' + - properties: + items: + items: + $ref: '#/definitions/Operation' + type: array + type: object + summary: Get all Operations by account + tags: + - Operations + /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{account_id}/operations/{operation_id}: + get: + description: Get an Operation with the input ID + parameters: + - description: Organization ID + in: path + name: organization_id + required: true + type: string + - description: Ledger ID + in: path + name: ledger_id + required: true + type: string + - description: Account ID + in: path + name: account_id + required: true + type: string + - description: Operation ID + in: path + name: operation_id + required: true + type: string + - description: Request ID + in: header + name: Midaz-Id + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/Operation' + summary: Get an Operation by account + tags: + - Operations + /v1/organizations/{organization_id}/ledgers/{ledger_id}/asset-rates: + post: + consumes: + - application/json + description: Create an AssetRate with the input payload + parameters: + - description: Organization ID + in: path + name: organization_id + required: true + type: string + - description: Ledger ID + in: path + name: ledger_id + required: true + type: string + - description: AssetRate Input + in: body + name: asset-rate + required: true + schema: + $ref: '#/definitions/CreateAssetRateInput' + - description: Request ID + in: header + name: Midaz-Id + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/AssetRate' + summary: Create an AssetRate + tags: + - Asset Rates + /v1/organizations/{organization_id}/ledgers/{ledger_id}/asset-rates/{asset_rate_id}: + get: + description: Get an AssetRate with the input ID + parameters: + - description: Organization ID + in: path + name: organization_id + required: true + type: string + - description: Ledger ID + in: path + name: ledger_id + required: true + type: string + - description: AssetRate ID + in: path + name: asset_rate_id + required: true + type: string + - description: AssetRate Input + in: body + name: asset-rate + required: true + schema: + $ref: '#/definitions/CreateAssetRateInput' + - description: Request ID + in: header + name: Midaz-Id + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/AssetRate' + summary: Get an AssetRate by ID + tags: + - Asset Rates + /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/operations: + get: + description: Get all Operations with the input ID + parameters: + - description: Organization ID + in: path + name: organization_id + required: true + type: string + - description: Ledger ID + in: path + name: ledger_id + required: true + type: string + - description: Portfolio ID + in: path + name: portfolio_id + required: true + type: string + - description: Request ID + in: header + name: Midaz-Id + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/Pagination' + - properties: + items: + items: + $ref: '#/definitions/Operation' + type: array + type: object + summary: Get all Operations by portfolio + tags: + - Operations + /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/operations/{operation_id}: + get: + description: Get an Operation with the input ID + parameters: + - description: Organization ID + in: path + name: organization_id + required: true + type: string + - description: Ledger ID + in: path + name: ledger_id + required: true + type: string + - description: Portfolio ID + in: path + name: portfolio_id + required: true + type: string + - description: Operation ID + in: path + name: operation_id + required: true + type: string + - description: Request ID + in: header + name: Midaz-Id + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/Operation' + summary: Get an Operation by portfolio + tags: + - Operations + /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions: + get: + description: Get all Transactions with the input metadata or without metadata + parameters: + - description: Organization ID + in: path + name: organization_id + required: true + type: string + - description: Ledger ID + in: path + name: ledger_id + required: true + type: string + - description: Request ID + in: header + name: Midaz-Id + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/Pagination' + - properties: + items: + items: + $ref: '#/definitions/Transaction' + type: array + type: object + summary: Get all Transactions + tags: + - Transactions + /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/{transaction_id}: + get: + description: Get a Transaction with the input ID + parameters: + - description: Organization ID + in: path + name: organization_id + required: true + type: string + - description: Ledger ID + in: path + name: ledger_id + required: true + type: string + - description: Transaction ID + in: path + name: transaction_id + required: true + type: string + - description: Request ID + in: header + name: Midaz-Id + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/Transaction' + summary: Get a Transaction by ID + tags: + - Transactions + patch: + consumes: + - application/json + description: Update a Transaction with the input payload + parameters: + - description: Organization ID + in: path + name: organization_id + required: true + type: string + - description: Ledger ID + in: path + name: ledger_id + required: true + type: string + - description: Transaction ID + in: path + name: transaction_id + required: true + type: string + - description: Transaction Input + in: body + name: transaction + required: true + schema: + $ref: '#/definitions/UpdateTransactionInput' + - description: Request ID + in: header + name: Midaz-Id + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/Transaction' + summary: Update a Transaction + tags: + - Transactions + /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/{transaction_id}/operations/{operation_id}: + patch: + consumes: + - application/json + description: Update an Operation with the input payload + parameters: + - description: Organization ID + in: path + name: organization_id + required: true + type: string + - description: Ledger ID + in: path + name: ledger_id + required: true + type: string + - description: Transaction ID + in: path + name: transaction_id + required: true + type: string + - description: Operation ID + in: path + name: operation_id + required: true + type: string + - description: Operation Input + in: body + name: operation + required: true + schema: + $ref: '#/definitions/UpdateOperationInput' + - description: Request ID + in: header + name: Midaz-Id + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/Operation' + summary: Update an Operation + tags: + - Operations + /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/dsl: + post: + consumes: + - multipart/form-data + description: Create a Transaction with the input DSL file + parameters: + - description: Organization ID + in: path + name: organization_id + required: true + type: string + - description: Ledger ID + in: path + name: ledger_id + required: true + type: string + - description: Transaction DSL file + in: formData + name: transaction + required: true + type: file + - description: Request ID + in: header + name: Midaz-Id + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/Transaction' + summary: Create a Transaction using DSL + tags: + - Transactions + /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/json: + post: + consumes: + - application/json + description: Create a Transaction with the input payload + parameters: + - description: Organization ID + in: path + name: organization_id + required: true + type: string + - description: Ledger ID + in: path + name: ledger_id + required: true + type: string + - description: Transaction Input + in: body + name: transaction + required: true + schema: + $ref: '#/definitions/CreateTransactionInput' + - description: Request ID + in: header + name: Midaz-Id + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/Transaction' + summary: Create a Transaction using JSON + tags: + - Transactions +swagger: "2.0" From b7633745d3390b6a7ab745b5bae9311489bdd2d3 Mon Sep 17 00:00:00 2001 From: Brecci Date: Mon, 25 Nov 2024 17:02:53 -0300 Subject: [PATCH 4/4] docs: enrich swagger models descriptions and examples :books: --- common/gold/transaction/model/transaction.go | 92 ++++-- common/mmodel/account.go | 10 +- common/mmodel/asset.go | 24 +- common/mmodel/ledger.go | 8 +- common/mmodel/organization.go | 10 +- common/mmodel/portfolio.go | 8 +- common/mmodel/product.go | 8 +- common/mmodel/status.go | 2 +- common/mpostgres/pagination.go | 2 +- components/ledger/api/docs.go | 44 +-- components/ledger/api/swagger.json | 44 +-- components/ledger/api/swagger.yaml | 59 ++-- .../ledger/internal/bootstrap/http/account.go | 20 +- .../ledger/internal/bootstrap/http/asset.go | 10 +- .../ledger/internal/bootstrap/http/ledger.go | 14 +- .../internal/bootstrap/http/organization.go | 12 +- .../internal/bootstrap/http/portfolio.go | 10 +- .../ledger/internal/bootstrap/http/product.go | 10 +- components/transaction/api/docs.go | 282 +++++++++--------- components/transaction/api/swagger.json | 282 +++++++++--------- components/transaction/api/swagger.yaml | 213 ++++++------- .../database/postgres/assetrate/assetrate.go | 4 +- .../database/postgres/operation/operation.go | 12 +- .../postgres/transaction/transaction.go | 11 +- .../internal/bootstrap/http/assetrate.go | 18 +- .../internal/bootstrap/http/operation.go | 28 +- .../internal/bootstrap/http/transaction.go | 34 +-- 27 files changed, 656 insertions(+), 615 deletions(-) diff --git a/common/gold/transaction/model/transaction.go b/common/gold/transaction/model/transaction.go index 014cf789..0751620f 100644 --- a/common/gold/transaction/model/transaction.go +++ b/common/gold/transaction/model/transaction.go @@ -1,10 +1,14 @@ package model +// Balance structure for marshaling/unmarshalling JSON. +// +// swagger:model Balance +// @Description Balance is the struct designed to represent the account balance. type Balance struct { - Available int `json:"available"` - OnHold int `json:"onHold"` - Scale int `json:"scale"` -} + Available int `json:"available" example:"1500"` + OnHold int `json:"onHold" example:"500"` + Scale int `json:"scale" example:"2"` +} // @name Balance type Responses struct { Total int @@ -15,57 +19,89 @@ type Responses struct { Aliases []string } +// Metadata structure for marshaling/unmarshalling JSON. +// +// swagger:model Metadata +// @Description Metadata is the struct designed to store metadata. type Metadata struct { Key string `json:"key,omitempty"` Value any `json:"value,omitempty"` -} +} // @name Metadata +// Amount structure for marshaling/unmarshalling JSON. +// +// swagger:model Amount +// @Description Amount is the struct designed to represent the amount of an operation. type Amount struct { - Asset string `json:"asset,omitempty" validate:"required,eq=BRL"` - Value int `json:"value,omitempty" validate:"required"` - Scale int `json:"scale,omitempty" validate:"gte=0"` -} + Asset string `json:"asset,omitempty" validate:"required,eq=BRL" example:"BRL"` + Value int `json:"value,omitempty" validate:"required" example:"1000"` + Scale int `json:"scale,omitempty" validate:"gte=0" example:"2"` +} // @name Amount +// Share structure for marshaling/unmarshalling JSON. +// +// swagger:model Share +// @Description Share is the struct designed to represent the sharing fields of an operation. type Share struct { Percentage int `json:"percentage,omitempty" validate:"required"` PercentageOfPercentage int `json:"percentageOfPercentage,omitempty"` DescWhatever bool `json:"descWhatever,omitempty"` -} +} // @name Share +// Send structure for marshaling/unmarshalling JSON. +// +// swagger:model Send +// @Description Send is the struct designed to represent the sending fields of an operation. type Send struct { - Asset string `json:"asset,omitempty" validate:"required,eq=BRL"` - Value int `json:"value,omitempty" validate:"required"` - Scale int `json:"scale,omitempty" validate:"gte=0"` + Asset string `json:"asset,omitempty" validate:"required,eq=BRL" example:"BRL"` + Value int `json:"value,omitempty" validate:"required" example:"1000"` + Scale int `json:"scale,omitempty" validate:"gte=0" example:"2"` Source Source `json:"source,omitempty" validate:"required"` -} +} // @name Send +// Source structure for marshaling/unmarshalling JSON. +// +// swagger:model Source +// @Description Source is the struct designed to represent the source fields of an operation. type Source struct { - Remaining string `json:"remaining,omitempty"` + Remaining string `json:"remaining,omitempty" example:"remaining"` From []FromTo `json:"from,omitempty" validate:"singletransactiontype,required,dive"` -} +} // @name Source +// FromTo structure for marshaling/unmarshalling JSON. +// +// swagger:model FromTo +// @Description FromTo is the struct designed to represent the from/to fields of an operation. type FromTo struct { - Account string `json:"account,omitempty"` + Account string `json:"account,omitempty" example:"@person1"` Amount *Amount `json:"amount,omitempty"` Share *Share `json:"share,omitempty"` - Remaining string `json:"remaining,omitempty"` - Description string `json:"description,omitempty"` - ChartOfAccounts string `json:"chartOfAccountsG"` + Remaining string `json:"remaining,omitempty" example:"remaining"` + Description string `json:"description,omitempty" example:"description"` + ChartOfAccounts string `json:"chartOfAccountsG" example:"1000"` Metadata map[string]any `json:"metadata,omitempty" validate:"dive,keys,keymax=100,endkeys,nonested,valuemax=2000"` - IsFrom bool `json:"isFrom,omitempty"` -} + IsFrom bool `json:"isFrom,omitempty" example:"true"` +} // @name FromTo +// Distribute structure for marshaling/unmarshalling JSON. +// +// swagger:model Distribute +// @Description Distribute is the struct designed to represent the distribution fields of an operation. type Distribute struct { Remaining string `json:"remaining,omitempty"` To []FromTo `json:"to,omitempty" validate:"singletransactiontype,required,dive"` -} +} // @name Distribute +// Transaction structure for marshaling/unmarshalling JSON. +// +// swagger:model Transaction +// @Description Transaction is a struct designed to store transaction data. type Transaction struct { - ChartOfAccountsGroupName string `json:"chartOfAccountsGroupName,omitempty"` - Description string `json:"description,omitempty"` - Code string `json:"code,omitempty"` - Pending bool `json:"pending,omitempty"` + ChartOfAccountsGroupName string `json:"chartOfAccountsGroupName,omitempty" example:"1000"` + Description string `json:"description,omitempty" example:"Description"` + Code string `json:"code,omitempty" example:"00000000-0000-0000-0000-000000000000"` + Pending bool `json:"pending,omitempty" example:"false"` Metadata map[string]any `json:"metadata,omitempty" validate:"dive,keys,keymax=100,endkeys,nonested,valuemax=2000"` Send Send `json:"send" validate:"required"` Distribute Distribute `json:"distribute" validate:"required"` -} +} // @name Transaction diff --git a/common/mmodel/account.go b/common/mmodel/account.go index 3c728864..346fa2c6 100644 --- a/common/mmodel/account.go +++ b/common/mmodel/account.go @@ -8,7 +8,7 @@ import ( // CreateAccountInput is a struct design to encapsulate request create payload data. // // swagger:model CreateAccountInput -// @Description CreateAccountInput is a struct design to encapsulate request create payload data. +// @Description CreateAccountInput is the input payload to create an account. type CreateAccountInput struct { AssetCode string `json:"assetCode" validate:"required,max=100" example:"BRL"` Name string `json:"name" validate:"max=256" example:"My Account"` @@ -27,7 +27,7 @@ type CreateAccountInput struct { // UpdateAccountInput is a struct design to encapsulate request update payload data. // // swagger:model UpdateAccountInput -// @Description UpdateAccountInput is a struct design to encapsulate request update payload data. +// @Description UpdateAccountInput is the input payload to update an account. type UpdateAccountInput struct { Name string `json:"name" validate:"max=256" example:"My Account Updated"` Status Status `json:"status"` @@ -41,7 +41,7 @@ type UpdateAccountInput struct { // Account is a struct designed to encapsulate response payload data. // // swagger:model Account -// @Description Account is a struct designed to encapsulate response payload data. +// @Description Account is a struct designed to store account data. type Account struct { ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"` Name string `json:"name" example:"My Account"` @@ -67,7 +67,7 @@ type Account struct { // Balance structure for marshaling/unmarshalling JSON. // // swagger:model Balance -// @Description Balance structure for marshaling/unmarshalling JSON. +// @Description Balance is the struct designed to represent the account balance. type Balance struct { Available *float64 `json:"available" example:"1500"` OnHold *float64 `json:"onHold" example:"500"` @@ -82,7 +82,7 @@ func (b Balance) IsEmpty() bool { // Accounts struct to return get all. // // swagger:model Accounts -// @Description Accounts struct to return get all. +// @Description Accounts is the struct designed to return a list of accounts with pagination. type Accounts struct { Items []Account `json:"items"` Page int `json:"page" example:"1"` diff --git a/common/mmodel/asset.go b/common/mmodel/asset.go index 107ebd9e..d7b78d3f 100644 --- a/common/mmodel/asset.go +++ b/common/mmodel/asset.go @@ -6,13 +6,7 @@ import "time" // // swagger:model CreateAssetInput // -// @Description CreateAssetInput is a struct design to encapsulate request create payload da -// @Description CreateAssetInput is a struct design to encapsulate request create payload data. -// @Param name query string false "Name" e -// @Param type query string false "Type" -// @Param code query string false "Code" -// @Param status query string false "Status" -// @Param metadata query string false "Metadata" +// @Description CreateAssetInput is the input payload to create an asset. type CreateAssetInput struct { Name string `json:"name" validate:"max=256" example:"Brazilian Real"` Type string `json:"type" example:"currency"` @@ -23,9 +17,9 @@ type CreateAssetInput struct { // UpdateAssetInput is a struct design to encapsulate request update payload data. // -ncapsulate request update payload // swagger:model UpdateAssetInput -// @Description UpdateAssetInput is a struct design to encapsulate request update payload data. +// +// @Description UpdateAssetInput is the input payload to update an asset. type UpdateAssetInput struct { Name string `json:"name" validate:"max=256" example:"Bitcoin"` Status Status `json:"status"` @@ -34,9 +28,9 @@ type UpdateAssetInput struct { // Asset is a struct designed to encapsulate payload data. // - string // swagger:model Asset -// @Description Asset is a struct designed to encapsulate payload data. +// +// @Description Asset is a struct designed to store asset data. type Asset struct { ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"` Name string `json:"name" example:"Brazilian Real"` @@ -53,13 +47,9 @@ type Asset struct { // Assets struct to return get all. // -string false "Page" -// // swagger:model Assets -// @Description Assets struct to return get all. -// @Param items query string false "Items" -// @Param page query string false "Page" -// @Param limit query string false "Limit" +// +// @Description Assets is the struct designed to return a list of assets with pagination. type Assets struct { Items []Asset `json:"items"` Page int `json:"page" example:"1"` diff --git a/common/mmodel/ledger.go b/common/mmodel/ledger.go index dcf69c4f..9f02951b 100644 --- a/common/mmodel/ledger.go +++ b/common/mmodel/ledger.go @@ -5,7 +5,7 @@ import "time" // CreateLedgerInput is a struct design to encapsulate request create payload data. // // swagger:model CreateLedgerInput -// @Description CreateLedgerInput is a struct design to encapsulate request create payload data for ledger. +// @Description CreateLedgerInput is the input payload to create a ledger. type CreateLedgerInput struct { Name string `json:"name" validate:"required,max=256" example:"Lerian Studio"` Status Status `json:"status"` @@ -15,7 +15,7 @@ type CreateLedgerInput struct { // UpdateLedgerInput is a struct design to encapsulate request update payload data. // // swagger:model UpdateLedgerInput -// @Description UpdateLedgerInput is a struct design to encapsulate request update payload data for ledger. +// @Description UpdateLedgerInput is the input payload to update a ledger. type UpdateLedgerInput struct { Name string `json:"name" validate:"max=256" example:"Lerian Studio Updated"` Status Status `json:"status"` @@ -25,7 +25,7 @@ type UpdateLedgerInput struct { // Ledger is a struct designed to encapsulate payload data. // // swagger:model Ledger -// @Description Ledger is a struct designed to encapsulate payload data. +// @Description Ledger is a struct designed to store ledger data. type Ledger struct { ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"` Name string `json:"name" example:"Lerian Studio"` @@ -40,7 +40,7 @@ type Ledger struct { // Ledgers struct to return get all. // // swagger:model Ledgers -// @Description Ledgers struct to return get all. +// @Description Ledgers is the struct designed to return a list of ledgers with pagination. type Ledgers struct { Items []Ledger `json:"items"` Page int `json:"page" example:"1"` diff --git a/common/mmodel/organization.go b/common/mmodel/organization.go index 8dc75b89..0a67db3d 100644 --- a/common/mmodel/organization.go +++ b/common/mmodel/organization.go @@ -5,7 +5,7 @@ import "time" // CreateOrganizationInput is a struct design to encapsulate request create payload data. // // // swagger:model CreateOrganizationInput -// @Description CreateOrganizationInput is a struct design to encapsulate request create payload data for organization. +// @Description CreateOrganizationInput is the input payload to create an organization. type CreateOrganizationInput struct { LegalName string `json:"legalName" validate:"required,max=256" example:"Lerian Studio"` ParentOrganizationID *string `json:"parentOrganizationId" validate:"omitempty,uuid" example:"00000000-0000-0000-0000-000000000000"` @@ -19,7 +19,7 @@ type CreateOrganizationInput struct { // UpdateOrganizationInput is a struct design to encapsulate request update payload data. // // // swagger:model UpdateOrganizationInput -// @Description UpdateOrganizationInput is a struct design to encapsulate request update payload data for organization. +// @Description UpdateOrganizationInput is the input payload to update an organization. type UpdateOrganizationInput struct { LegalName string `json:"legalName" validate:"required,max=256" example:"Lerian Studio Updated"` ParentOrganizationID *string `json:"parentOrganizationId" validate:"omitempty,uuid" example:"00000000-0000-0000-0000-000000000000"` @@ -32,7 +32,7 @@ type UpdateOrganizationInput struct { // Organization is a struct designed to encapsulate response payload data. // // swagger:model Organization -// @Description Organization is a struct designed to encapsulate response payload data. +// @Description Organization is a struct designed to store organization data. type Organization struct { ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"` ParentOrganizationID *string `json:"parentOrganizationId" example:"00000000-0000-0000-0000-000000000000"` @@ -50,7 +50,7 @@ type Organization struct { // Address structure for marshaling/unmarshalling JSON. // // swagger:model Address -// @Description Address structure for marshaling/unmarshalling JSON. +// @Description Address is a struct designed to store the address data of an organization. type Address struct { Line1 string `json:"line1" example:"Street 1"` Line2 *string `json:"line2" example:"Street 2"` @@ -68,7 +68,7 @@ func (a Address) IsEmpty() bool { // Organizations struct to return get all. // // swagger:model Organizations -// @Description Organizations struct to return get all. +// @Description Organizations is the struct designed to return a list of organizations with pagination. type Organizations struct { Items []Organization `json:"items"` Page int `json:"page" example:"1"` diff --git a/common/mmodel/portfolio.go b/common/mmodel/portfolio.go index cca0f24d..357235dc 100644 --- a/common/mmodel/portfolio.go +++ b/common/mmodel/portfolio.go @@ -5,7 +5,7 @@ import "time" // CreatePortfolioInput is a struct design to encapsulate request create payload data. // // swagger:model CreatePortfolioInput -// @Description CreatePortfolioInput is a struct design to encapsulate request create payload data. +// @Description CreatePortfolioInput is the input payload to create a portfolio. type CreatePortfolioInput struct { EntityID string `json:"entityId" validate:"required,max=256" example:"00000000-0000-0000-0000-000000000000"` Name string `json:"name" validate:"required,max=256" example:"My Portfolio"` @@ -16,7 +16,7 @@ type CreatePortfolioInput struct { // UpdatePortfolioInput is a struct design to encapsulate payload data. // // swagger:model UpdatePortfolioInput -// @Description UpdatePortfolioInput is a struct design to encapsulate payload data. +// @Description UpdatePortfolioInput is the input payload to update a portfolio. type UpdatePortfolioInput struct { Name string `json:"name" validate:"max=256" example:"My Portfolio Updated"` Status Status `json:"status"` @@ -26,7 +26,7 @@ type UpdatePortfolioInput struct { // Portfolio is a struct designed to encapsulate request update payload data. // // swagger:model Portfolio -// @Description Portfolio is a struct designed to encapsulate request update payload data. +// @Description Portfolio is a struct designed to store portfolio data. type Portfolio struct { ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"` Name string `json:"name" example:"My Portfolio"` @@ -43,7 +43,7 @@ type Portfolio struct { // Portfolios struct to return get all. // // swagger:model Portfolios -// @Description Portfolios struct to return get all. +// @Description Portfolios is the struct designed to return a list of portfolios with pagination. type Portfolios struct { Items []Portfolio `json:"items"` Page int `json:"page" example:"1"` diff --git a/common/mmodel/product.go b/common/mmodel/product.go index 7fe05a3d..7d6de61c 100644 --- a/common/mmodel/product.go +++ b/common/mmodel/product.go @@ -5,7 +5,7 @@ import "time" // CreateProductInput is a struct design to encapsulate request create payload data. // // swagger:model CreateProductInput -// @Description CreateProductInput is a struct design to encapsulate request create payload data. +// @Description CreateProductInput is the input payload to create a product. type CreateProductInput struct { Name string `json:"name" validate:"required,max=256" example:"My Product"` Status Status `json:"status"` @@ -15,7 +15,7 @@ type CreateProductInput struct { // UpdateProductInput is a struct design to encapsulate request update payload data. // // swagger:model UpdateProductInput -// @Description UpdateProductInput is a struct design to encapsulate request update payload data. +// @Description UpdateProductInput is the input payload to update a product. type UpdateProductInput struct { Name string `json:"name" validate:"max=256" example:"My Product Updated"` Status Status `json:"status"` @@ -25,7 +25,7 @@ type UpdateProductInput struct { // Product is a struct designed to encapsulate payload data. // // swagger:model Product -// @Description Product is a struct designed to encapsulate payload data. +// @Description Product is a struct designed to store product data. type Product struct { ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"` Name string `json:"name" example:"My Product"` @@ -41,7 +41,7 @@ type Product struct { // Products struct to return get all. // // swagger:model Products -// @Description Products struct to return get all. +// @Description Products is the struct designed to return a list of products with pagination. type Products struct { Items []Product `json:"items"` Page int `json:"page" example:"1"` diff --git a/common/mmodel/status.go b/common/mmodel/status.go index b8c7dccc..fc7459d2 100644 --- a/common/mmodel/status.go +++ b/common/mmodel/status.go @@ -3,7 +3,7 @@ package mmodel // Status structure for marshaling/unmarshalling JSON. // // swagger:model Status -// @Description Status structure for marshaling/unmarshalling JSON. +// @Description Status is the struct designed to store the status data of an entity. type Status struct { Code string `json:"code" validate:"max=100" example:"ACTIVE"` Description *string `json:"description" validate:"omitempty,max=256" example:"Active status"` diff --git a/common/mpostgres/pagination.go b/common/mpostgres/pagination.go index 92fa5f72..395f750f 100644 --- a/common/mpostgres/pagination.go +++ b/common/mpostgres/pagination.go @@ -3,7 +3,7 @@ package mpostgres // Pagination is a struct designed to encapsulate pagination response payload data. // // swagger:model Pagination -// @Description Pagination is a struct designed to encapsulate pagination response payload data. +// @Description Pagination is the struct designed to store the pagination data of an entity list. type Pagination struct { Items any `json:"items"` Page int `json:"page" example:"1"` diff --git a/components/ledger/api/docs.go b/components/ledger/api/docs.go index a4c3b135..3736481c 100644 --- a/components/ledger/api/docs.go +++ b/components/ledger/api/docs.go @@ -1784,7 +1784,7 @@ const docTemplate = `{ }, "definitions": { "Account": { - "description": "Account is a struct designed to encapsulate response payload data.", + "description": "Account is a struct designed to store account data.", "type": "object", "properties": { "alias": { @@ -1864,7 +1864,7 @@ const docTemplate = `{ } }, "Address": { - "description": "Address structure for marshaling/unmarshalling JSON.", + "description": "Address is a struct designed to store the address data of an organization.", "type": "object", "properties": { "city": { @@ -1895,7 +1895,7 @@ const docTemplate = `{ } }, "Asset": { - "description": "Asset is a struct designed to encapsulate payload data.", + "description": "Asset is a struct designed to store asset data.", "type": "object", "properties": { "code": { @@ -1944,7 +1944,7 @@ const docTemplate = `{ } }, "Balance": { - "description": "Balance structure for marshaling/unmarshalling JSON.", + "description": "Balance is the struct designed to represent the account balance.", "type": "object", "properties": { "available": { @@ -1962,7 +1962,7 @@ const docTemplate = `{ } }, "CreateAccountInput": { - "description": "CreateAccountInput is a struct design to encapsulate request create payload data.", + "description": "CreateAccountInput is the input payload to create an account.", "type": "object", "required": [ "assetCode", @@ -2023,7 +2023,7 @@ const docTemplate = `{ } }, "CreateAssetInput": { - "description": "CreateAssetInput is a struct design to encapsulate request create payload data.", + "description": "CreateAssetInput is the input payload to create an asset.", "type": "object", "required": [ "code" @@ -2053,7 +2053,7 @@ const docTemplate = `{ } }, "CreateLedgerInput": { - "description": "CreateLedgerInput is a struct design to encapsulate request create payload data for ledger.", + "description": "CreateLedgerInput is the input payload to create a ledger.", "type": "object", "required": [ "name" @@ -2074,7 +2074,7 @@ const docTemplate = `{ } }, "CreateOrganizationInput": { - "description": "CreateOrganizationInput is a struct design to encapsulate request create payload data for organization.", + "description": "CreateOrganizationInput is the input payload to create an organization.", "type": "object", "required": [ "legalDocument", @@ -2113,7 +2113,7 @@ const docTemplate = `{ } }, "CreatePortfolioInput": { - "description": "CreatePortfolioInput is a struct design to encapsulate request create payload data.", + "description": "CreatePortfolioInput is the input payload to create a portfolio.", "type": "object", "required": [ "entityId", @@ -2140,7 +2140,7 @@ const docTemplate = `{ } }, "CreateProductInput": { - "description": "CreateProductInput is a struct design to encapsulate request create payload data.", + "description": "CreateProductInput is the input payload to create a product.", "type": "object", "required": [ "name" @@ -2161,7 +2161,7 @@ const docTemplate = `{ } }, "Ledger": { - "description": "Ledger is a struct designed to encapsulate payload data.", + "description": "Ledger is a struct designed to store ledger data.", "type": "object", "properties": { "createdAt": { @@ -2198,7 +2198,7 @@ const docTemplate = `{ } }, "Organization": { - "description": "Organization is a struct designed to encapsulate response payload data.", + "description": "Organization is a struct designed to store organization data.", "type": "object", "properties": { "address": { @@ -2246,7 +2246,7 @@ const docTemplate = `{ } }, "Pagination": { - "description": "Pagination is a struct designed to encapsulate pagination response payload data.", + "description": "Pagination is the struct designed to store the pagination data of an entity list.", "type": "object", "properties": { "items": {}, @@ -2261,7 +2261,7 @@ const docTemplate = `{ } }, "Portfolio": { - "description": "Portfolio is a struct designed to encapsulate request update payload data.", + "description": "Portfolio is a struct designed to store portfolio data.", "type": "object", "properties": { "createdAt": { @@ -2306,7 +2306,7 @@ const docTemplate = `{ } }, "Product": { - "description": "Product is a struct designed to encapsulate payload data.", + "description": "Product is a struct designed to store product data.", "type": "object", "properties": { "createdAt": { @@ -2347,7 +2347,7 @@ const docTemplate = `{ } }, "Status": { - "description": "Status structure for marshaling/unmarshalling JSON.", + "description": "Status is the struct designed to store the status data of an entity.", "type": "object", "properties": { "code": { @@ -2363,7 +2363,7 @@ const docTemplate = `{ } }, "UpdateAccountInput": { - "description": "UpdateAccountInput is a struct design to encapsulate request update payload data.", + "description": "UpdateAccountInput is the input payload to update an account.", "type": "object", "properties": { "alias": { @@ -2398,7 +2398,7 @@ const docTemplate = `{ } }, "UpdateAssetInput": { - "description": "UpdateAssetInput is a struct design to encapsulate request update payload data.", + "description": "UpdateAssetInput is the input payload to update an asset.", "type": "object", "properties": { "metadata": { @@ -2416,7 +2416,7 @@ const docTemplate = `{ } }, "UpdateLedgerInput": { - "description": "UpdateLedgerInput is a struct design to encapsulate request update payload data for ledger.", + "description": "UpdateLedgerInput is the input payload to update a ledger.", "type": "object", "properties": { "metadata": { @@ -2434,7 +2434,7 @@ const docTemplate = `{ } }, "UpdateOrganizationInput": { - "description": "UpdateOrganizationInput is a struct design to encapsulate request update payload data for organization.", + "description": "UpdateOrganizationInput is the input payload to update an organization.", "type": "object", "required": [ "legalName" @@ -2467,7 +2467,7 @@ const docTemplate = `{ } }, "UpdatePortfolioInput": { - "description": "UpdatePortfolioInput is a struct design to encapsulate payload data.", + "description": "UpdatePortfolioInput is the input payload to update a portfolio.", "type": "object", "properties": { "metadata": { @@ -2485,7 +2485,7 @@ const docTemplate = `{ } }, "UpdateProductInput": { - "description": "UpdateProductInput is a struct design to encapsulate request update payload data.", + "description": "UpdateProductInput is the input payload to update a product.", "type": "object", "properties": { "metadata": { diff --git a/components/ledger/api/swagger.json b/components/ledger/api/swagger.json index 6697a9c8..ae812e3d 100644 --- a/components/ledger/api/swagger.json +++ b/components/ledger/api/swagger.json @@ -1778,7 +1778,7 @@ }, "definitions": { "Account": { - "description": "Account is a struct designed to encapsulate response payload data.", + "description": "Account is a struct designed to store account data.", "type": "object", "properties": { "alias": { @@ -1858,7 +1858,7 @@ } }, "Address": { - "description": "Address structure for marshaling/unmarshalling JSON.", + "description": "Address is a struct designed to store the address data of an organization.", "type": "object", "properties": { "city": { @@ -1889,7 +1889,7 @@ } }, "Asset": { - "description": "Asset is a struct designed to encapsulate payload data.", + "description": "Asset is a struct designed to store asset data.", "type": "object", "properties": { "code": { @@ -1938,7 +1938,7 @@ } }, "Balance": { - "description": "Balance structure for marshaling/unmarshalling JSON.", + "description": "Balance is the struct designed to represent the account balance.", "type": "object", "properties": { "available": { @@ -1956,7 +1956,7 @@ } }, "CreateAccountInput": { - "description": "CreateAccountInput is a struct design to encapsulate request create payload data.", + "description": "CreateAccountInput is the input payload to create an account.", "type": "object", "required": [ "assetCode", @@ -2017,7 +2017,7 @@ } }, "CreateAssetInput": { - "description": "CreateAssetInput is a struct design to encapsulate request create payload data.", + "description": "CreateAssetInput is the input payload to create an asset.", "type": "object", "required": [ "code" @@ -2047,7 +2047,7 @@ } }, "CreateLedgerInput": { - "description": "CreateLedgerInput is a struct design to encapsulate request create payload data for ledger.", + "description": "CreateLedgerInput is the input payload to create a ledger.", "type": "object", "required": [ "name" @@ -2068,7 +2068,7 @@ } }, "CreateOrganizationInput": { - "description": "CreateOrganizationInput is a struct design to encapsulate request create payload data for organization.", + "description": "CreateOrganizationInput is the input payload to create an organization.", "type": "object", "required": [ "legalDocument", @@ -2107,7 +2107,7 @@ } }, "CreatePortfolioInput": { - "description": "CreatePortfolioInput is a struct design to encapsulate request create payload data.", + "description": "CreatePortfolioInput is the input payload to create a portfolio.", "type": "object", "required": [ "entityId", @@ -2134,7 +2134,7 @@ } }, "CreateProductInput": { - "description": "CreateProductInput is a struct design to encapsulate request create payload data.", + "description": "CreateProductInput is the input payload to create a product.", "type": "object", "required": [ "name" @@ -2155,7 +2155,7 @@ } }, "Ledger": { - "description": "Ledger is a struct designed to encapsulate payload data.", + "description": "Ledger is a struct designed to store ledger data.", "type": "object", "properties": { "createdAt": { @@ -2192,7 +2192,7 @@ } }, "Organization": { - "description": "Organization is a struct designed to encapsulate response payload data.", + "description": "Organization is a struct designed to store organization data.", "type": "object", "properties": { "address": { @@ -2240,7 +2240,7 @@ } }, "Pagination": { - "description": "Pagination is a struct designed to encapsulate pagination response payload data.", + "description": "Pagination is the struct designed to store the pagination data of an entity list.", "type": "object", "properties": { "items": {}, @@ -2255,7 +2255,7 @@ } }, "Portfolio": { - "description": "Portfolio is a struct designed to encapsulate request update payload data.", + "description": "Portfolio is a struct designed to store portfolio data.", "type": "object", "properties": { "createdAt": { @@ -2300,7 +2300,7 @@ } }, "Product": { - "description": "Product is a struct designed to encapsulate payload data.", + "description": "Product is a struct designed to store product data.", "type": "object", "properties": { "createdAt": { @@ -2341,7 +2341,7 @@ } }, "Status": { - "description": "Status structure for marshaling/unmarshalling JSON.", + "description": "Status is the struct designed to store the status data of an entity.", "type": "object", "properties": { "code": { @@ -2357,7 +2357,7 @@ } }, "UpdateAccountInput": { - "description": "UpdateAccountInput is a struct design to encapsulate request update payload data.", + "description": "UpdateAccountInput is the input payload to update an account.", "type": "object", "properties": { "alias": { @@ -2392,7 +2392,7 @@ } }, "UpdateAssetInput": { - "description": "UpdateAssetInput is a struct design to encapsulate request update payload data.", + "description": "UpdateAssetInput is the input payload to update an asset.", "type": "object", "properties": { "metadata": { @@ -2410,7 +2410,7 @@ } }, "UpdateLedgerInput": { - "description": "UpdateLedgerInput is a struct design to encapsulate request update payload data for ledger.", + "description": "UpdateLedgerInput is the input payload to update a ledger.", "type": "object", "properties": { "metadata": { @@ -2428,7 +2428,7 @@ } }, "UpdateOrganizationInput": { - "description": "UpdateOrganizationInput is a struct design to encapsulate request update payload data for organization.", + "description": "UpdateOrganizationInput is the input payload to update an organization.", "type": "object", "required": [ "legalName" @@ -2461,7 +2461,7 @@ } }, "UpdatePortfolioInput": { - "description": "UpdatePortfolioInput is a struct design to encapsulate payload data.", + "description": "UpdatePortfolioInput is the input payload to update a portfolio.", "type": "object", "properties": { "metadata": { @@ -2479,7 +2479,7 @@ } }, "UpdateProductInput": { - "description": "UpdateProductInput is a struct design to encapsulate request update payload data.", + "description": "UpdateProductInput is the input payload to update a product.", "type": "object", "properties": { "metadata": { diff --git a/components/ledger/api/swagger.yaml b/components/ledger/api/swagger.yaml index bb5f9c84..44867a5b 100644 --- a/components/ledger/api/swagger.yaml +++ b/components/ledger/api/swagger.yaml @@ -1,7 +1,7 @@ basePath: / definitions: Account: - description: Account is a struct designed to encapsulate response payload data. + description: Account is a struct designed to store account data. properties: alias: example: '@person1' @@ -60,7 +60,7 @@ definitions: type: string type: object Address: - description: Address structure for marshaling/unmarshalling JSON. + description: Address is a struct designed to store the address data of an organization. properties: city: example: New York @@ -83,7 +83,7 @@ definitions: type: string type: object Asset: - description: Asset is a struct designed to encapsulate payload data. + description: Asset is a struct designed to store asset data. properties: code: example: BRL @@ -119,7 +119,7 @@ definitions: type: string type: object Balance: - description: Balance structure for marshaling/unmarshalling JSON. + description: Balance is the struct designed to represent the account balance. properties: available: example: 1500 @@ -132,8 +132,7 @@ definitions: type: number type: object CreateAccountInput: - description: CreateAccountInput is a struct design to encapsulate request create - payload data. + description: CreateAccountInput is the input payload to create an account. properties: alias: example: '@person1' @@ -179,8 +178,7 @@ definitions: - type type: object CreateAssetInput: - description: CreateAssetInput is a struct design to encapsulate request create - payload data. + description: CreateAssetInput is the input payload to create an asset. properties: code: example: BRL @@ -202,8 +200,7 @@ definitions: - code type: object CreateLedgerInput: - description: CreateLedgerInput is a struct design to encapsulate request create - payload data for ledger. + description: CreateLedgerInput is the input payload to create a ledger. properties: metadata: additionalProperties: {} @@ -218,8 +215,7 @@ definitions: - name type: object CreateOrganizationInput: - description: CreateOrganizationInput is a struct design to encapsulate request - create payload data for organization. + description: CreateOrganizationInput is the input payload to create an organization. properties: address: $ref: '#/definitions/Address' @@ -248,8 +244,7 @@ definitions: - legalName type: object CreatePortfolioInput: - description: CreatePortfolioInput is a struct design to encapsulate request create - payload data. + description: CreatePortfolioInput is the input payload to create a portfolio. properties: entityId: example: 00000000-0000-0000-0000-000000000000 @@ -269,8 +264,7 @@ definitions: - name type: object CreateProductInput: - description: CreateProductInput is a struct design to encapsulate request create - payload data. + description: CreateProductInput is the input payload to create a product. properties: metadata: additionalProperties: {} @@ -285,7 +279,7 @@ definitions: - name type: object Ledger: - description: Ledger is a struct designed to encapsulate payload data. + description: Ledger is a struct designed to store ledger data. properties: createdAt: example: "2021-01-01T00:00:00Z" @@ -312,8 +306,7 @@ definitions: type: string type: object Organization: - description: Organization is a struct designed to encapsulate response payload - data. + description: Organization is a struct designed to store organization data. properties: address: $ref: '#/definitions/Address' @@ -348,8 +341,8 @@ definitions: type: string type: object Pagination: - description: Pagination is a struct designed to encapsulate pagination response - payload data. + description: Pagination is the struct designed to store the pagination data of + an entity list. properties: items: {} limit: @@ -360,8 +353,7 @@ definitions: type: integer type: object Portfolio: - description: Portfolio is a struct designed to encapsulate request update payload - data. + description: Portfolio is a struct designed to store portfolio data. properties: createdAt: example: "2021-01-01T00:00:00Z" @@ -394,7 +386,7 @@ definitions: type: string type: object Product: - description: Product is a struct designed to encapsulate payload data. + description: Product is a struct designed to store product data. properties: createdAt: example: "2021-01-01T00:00:00Z" @@ -424,7 +416,7 @@ definitions: type: string type: object Status: - description: Status structure for marshaling/unmarshalling JSON. + description: Status is the struct designed to store the status data of an entity. properties: code: example: ACTIVE @@ -436,8 +428,7 @@ definitions: type: string type: object UpdateAccountInput: - description: UpdateAccountInput is a struct design to encapsulate request update - payload data. + description: UpdateAccountInput is the input payload to update an account. properties: alias: example: '@person1' @@ -463,8 +454,7 @@ definitions: $ref: '#/definitions/Status' type: object UpdateAssetInput: - description: UpdateAssetInput is a struct design to encapsulate request update - payload data. + description: UpdateAssetInput is the input payload to update an asset. properties: metadata: additionalProperties: {} @@ -477,8 +467,7 @@ definitions: $ref: '#/definitions/Status' type: object UpdateLedgerInput: - description: UpdateLedgerInput is a struct design to encapsulate request update - payload data for ledger. + description: UpdateLedgerInput is the input payload to update a ledger. properties: metadata: additionalProperties: {} @@ -491,8 +480,7 @@ definitions: $ref: '#/definitions/Status' type: object UpdateOrganizationInput: - description: UpdateOrganizationInput is a struct design to encapsulate request - update payload data for organization. + description: UpdateOrganizationInput is the input payload to update an organization. properties: address: $ref: '#/definitions/Address' @@ -516,7 +504,7 @@ definitions: - legalName type: object UpdatePortfolioInput: - description: UpdatePortfolioInput is a struct design to encapsulate payload data. + description: UpdatePortfolioInput is the input payload to update a portfolio. properties: metadata: additionalProperties: {} @@ -529,8 +517,7 @@ definitions: $ref: '#/definitions/Status' type: object UpdateProductInput: - description: UpdateProductInput is a struct design to encapsulate request update - payload data. + description: UpdateProductInput is the input payload to update a product. properties: metadata: additionalProperties: {} diff --git a/components/ledger/internal/bootstrap/http/account.go b/components/ledger/internal/bootstrap/http/account.go index d39cdd5e..25d55002 100644 --- a/components/ledger/internal/bootstrap/http/account.go +++ b/components/ledger/internal/bootstrap/http/account.go @@ -29,7 +29,7 @@ type AccountHandler struct { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param account body mmodel.CreateAccountInput true "Account" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Account // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts [post] func (handler *AccountHandler) CreateAccount(i any, c *fiber.Ctx) error { @@ -79,7 +79,7 @@ func (handler *AccountHandler) CreateAccount(i any, c *fiber.Ctx) error { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param metadata query string false "Metadata" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Account} // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts [get] func (handler *AccountHandler) GetAllAccounts(c *fiber.Ctx) error { @@ -158,7 +158,7 @@ func (handler *AccountHandler) GetAllAccounts(c *fiber.Ctx) error { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param id path string true "Account ID" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Account // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{id} [get] func (handler *AccountHandler) GetAccountByID(c *fiber.Ctx) error { @@ -201,7 +201,7 @@ func (handler *AccountHandler) GetAccountByID(c *fiber.Ctx) error { // @Param ledger_id path string true "Ledger ID" // @Param id path string true "Account ID" // @Param account body mmodel.UpdateAccountInput true "Account" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Account // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{id} [patch] func (handler *AccountHandler) UpdateAccount(i any, c *fiber.Ctx) error { @@ -260,7 +260,7 @@ func (handler *AccountHandler) UpdateAccount(i any, c *fiber.Ctx) error { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param id path string true "Account ID" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 204 // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{id} [delete] func (handler *AccountHandler) DeleteAccountByID(c *fiber.Ctx) error { @@ -308,7 +308,7 @@ func (handler *AccountHandler) DeleteAccountByID(c *fiber.Ctx) error { // @Param ledger_id path string true "Ledger ID" // @Param portfolio_id path string true "Portfolio ID" // @Param account body mmodel.CreateAccountInput true "Account" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Account // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/accounts [post] func (handler *AccountHandler) CreateAccountFromPortfolio(i any, c *fiber.Ctx) error { @@ -351,7 +351,7 @@ func (handler *AccountHandler) CreateAccountFromPortfolio(i any, c *fiber.Ctx) e // @Param ledger_id path string true "Ledger ID" // @Param portfolio_id path string true "Portfolio ID" // @Param metadata query string false "Metadata" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Account} // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/accounts [get] func (handler *AccountHandler) GetAllAccountsByIDFromPortfolio(c *fiber.Ctx) error { @@ -420,7 +420,7 @@ func (handler *AccountHandler) GetAllAccountsByIDFromPortfolio(c *fiber.Ctx) err // @Param ledger_id path string true "Ledger ID" // @Param portfolio_id path string true "Portfolio ID" // @Param id path string true "Account ID" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Account // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/accounts/{id} [get] func (handler *AccountHandler) GetAccountByIDFromPortfolio(c *fiber.Ctx) error { @@ -462,7 +462,7 @@ func (handler *AccountHandler) GetAccountByIDFromPortfolio(c *fiber.Ctx) error { // @Param portfolio_id path string true "Portfolio ID" // @Param id path string true "Account ID" // @Param account body mmodel.UpdateAccountInput true "Account" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Account // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/accounts/{id} [patch] func (handler *AccountHandler) UpdateAccountFromPortfolio(i any, c *fiber.Ctx) error { @@ -510,7 +510,7 @@ func (handler *AccountHandler) UpdateAccountFromPortfolio(i any, c *fiber.Ctx) e // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param portfolio_id path string true "Portfolio ID" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 204 // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/accounts/{id} [delete] func (handler *AccountHandler) DeleteAccountByIDFromPortfolio(c *fiber.Ctx) error { diff --git a/components/ledger/internal/bootstrap/http/asset.go b/components/ledger/internal/bootstrap/http/asset.go index 9736c98f..21fdaf29 100644 --- a/components/ledger/internal/bootstrap/http/asset.go +++ b/components/ledger/internal/bootstrap/http/asset.go @@ -29,7 +29,7 @@ type AssetHandler struct { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param asset body mmodel.CreateAssetInput true "Asset Input" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Asset // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/assets [post] func (handler *AssetHandler) CreateAsset(a any, c *fiber.Ctx) error { @@ -80,7 +80,7 @@ func (handler *AssetHandler) CreateAsset(a any, c *fiber.Ctx) error { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param metadata query string false "Metadata" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Asset} // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/assets [get] func (handler *AssetHandler) GetAllAssets(c *fiber.Ctx) error { @@ -153,7 +153,7 @@ func (handler *AssetHandler) GetAllAssets(c *fiber.Ctx) error { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param id path string true "Asset ID" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Asset // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/assets/{id} [get] func (handler *AssetHandler) GetAssetByID(c *fiber.Ctx) error { @@ -196,7 +196,7 @@ func (handler *AssetHandler) GetAssetByID(c *fiber.Ctx) error { // @Param ledger_id path string true "Ledger ID" // @Param id path string true "Asset ID" // @Param asset body mmodel.UpdateAssetInput true "Asset Input" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Asset // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/assets/{id} [patch] func (handler *AssetHandler) UpdateAsset(a any, c *fiber.Ctx) error { @@ -255,7 +255,7 @@ func (handler *AssetHandler) UpdateAsset(a any, c *fiber.Ctx) error { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param id path string true "Asset ID" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 204 // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/assets/{id} [delete] func (handler *AssetHandler) DeleteAssetByID(c *fiber.Ctx) error { diff --git a/components/ledger/internal/bootstrap/http/ledger.go b/components/ledger/internal/bootstrap/http/ledger.go index 41674470..6363905c 100644 --- a/components/ledger/internal/bootstrap/http/ledger.go +++ b/components/ledger/internal/bootstrap/http/ledger.go @@ -32,7 +32,7 @@ type LedgerHandler struct { // @Produce json // @Param organization_id path string true "Organization ID" // @Param ledger body mmodel.CreateLedgerInput true "Ledger Input" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Ledger // @Router /v1/organizations/{organization_id}/ledgers [post] func (handler *LedgerHandler) CreateLedger(i any, c *fiber.Ctx) error { @@ -75,9 +75,9 @@ func (handler *LedgerHandler) CreateLedger(i any, c *fiber.Ctx) error { // @Description Get a Ledger with the input ID // @Tags Ledgers // @Produce json -// @Param id path string true "Ledger ID" -// @Param Midaz-Id header string false "Request ID" -// @Success 200 {object} mmodel.Ledger +// @Param id path string true "Ledger ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Ledger // @Router /v1/organizations/{organization_id}/ledgers/{id} [get] func (handler *LedgerHandler) GetLedgerByID(c *fiber.Ctx) error { ctx := c.UserContext() @@ -115,7 +115,7 @@ func (handler *LedgerHandler) GetLedgerByID(c *fiber.Ctx) error { // @Produce json // @Param organization_id path string true "Organization ID" // @Param id path string true "Ledger ID" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Ledger} // @Router /v1/organizations/{organization_id}/ledgers [get] func (handler *LedgerHandler) GetAllLedgers(c *fiber.Ctx) error { @@ -185,7 +185,7 @@ func (handler *LedgerHandler) GetAllLedgers(c *fiber.Ctx) error { // @Param organization_id path string true "Organization ID" // @Param id path string true "Ledger ID" // @Param ledger body mmodel.UpdateLedgerInput true "Ledger Input" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Ledger // @Router /v1/organizations/{organization_id}/ledgers/{id} [patch] func (handler *LedgerHandler) UpdateLedger(p any, c *fiber.Ctx) error { @@ -242,7 +242,7 @@ func (handler *LedgerHandler) UpdateLedger(p any, c *fiber.Ctx) error { // @Tags Ledgers // @Param organization_id path string true "Organization ID" // @Param id path string true "Ledger ID" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 204 // @Router /v1/organizations/{organization_id}/ledgers/{id} [delete] func (handler *LedgerHandler) DeleteLedgerByID(c *fiber.Ctx) error { diff --git a/components/ledger/internal/bootstrap/http/organization.go b/components/ledger/internal/bootstrap/http/organization.go index 5b80459e..667ece82 100644 --- a/components/ledger/internal/bootstrap/http/organization.go +++ b/components/ledger/internal/bootstrap/http/organization.go @@ -128,9 +128,9 @@ func (handler *OrganizationHandler) UpdateOrganization(p any, c *fiber.Ctx) erro // @Description Get an Organization with the input ID // @Tags Organizations // @Produce json -// @Param id path string true "Organization ID" -// @Param Midaz-Id header string false "Request ID" -// @Success 200 {object} mmodel.Organization +// @Param id path string true "Organization ID" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mmodel.Organization // @Router /v1/organizations/{id} [get] func (handler *OrganizationHandler) GetOrganizationByID(c *fiber.Ctx) error { ctx := c.UserContext() @@ -165,7 +165,7 @@ func (handler *OrganizationHandler) GetOrganizationByID(c *fiber.Ctx) error { // @Tags Organizations // @Produce json // @Param metadata query string false "Metadata" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Organization} // @Router /v1/organizations [get] func (handler *OrganizationHandler) GetAllOrganizations(c *fiber.Ctx) error { @@ -227,8 +227,8 @@ func (handler *OrganizationHandler) GetAllOrganizations(c *fiber.Ctx) error { // @Summary Delete an Organization by ID // @Description Delete an Organization with the input ID // @Tags Organizations -// @Param id path string true "Organization ID" -// @Param Midaz-Id header string false "Request ID" +// @Param id path string true "Organization ID" +// @Param Midaz-Id header string false "Request ID" // @Success 204 // @Router /v1/organizations/{id} [delete] func (handler *OrganizationHandler) DeleteOrganizationByID(c *fiber.Ctx) error { diff --git a/components/ledger/internal/bootstrap/http/portfolio.go b/components/ledger/internal/bootstrap/http/portfolio.go index 291d5b52..c348e500 100644 --- a/components/ledger/internal/bootstrap/http/portfolio.go +++ b/components/ledger/internal/bootstrap/http/portfolio.go @@ -29,7 +29,7 @@ type PortfolioHandler struct { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param portfolio body mmodel.CreatePortfolioInput true "Portfolio Payload" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Portfolio // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios [post] func (handler *PortfolioHandler) CreatePortfolio(i any, c *fiber.Ctx) error { @@ -78,7 +78,7 @@ func (handler *PortfolioHandler) CreatePortfolio(i any, c *fiber.Ctx) error { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param metadata query string false "Metadata query" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Portfolio} // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios [get] func (handler *PortfolioHandler) GetAllPortfolios(c *fiber.Ctx) error { @@ -149,7 +149,7 @@ func (handler *PortfolioHandler) GetAllPortfolios(c *fiber.Ctx) error { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param id path string true "Portfolio ID" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Portfolio // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{id} [get] func (handler *PortfolioHandler) GetPortfolioByID(c *fiber.Ctx) error { @@ -191,7 +191,7 @@ func (handler *PortfolioHandler) GetPortfolioByID(c *fiber.Ctx) error { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param portfolio body mmodel.UpdatePortfolioInput true "Portfolio Payload" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Portfolio // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{id} [patch] func (handler *PortfolioHandler) UpdatePortfolio(i any, c *fiber.Ctx) error { @@ -250,7 +250,7 @@ func (handler *PortfolioHandler) UpdatePortfolio(i any, c *fiber.Ctx) error { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param id path string true "Portfolio ID" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 204 // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{id} [delete] func (handler *PortfolioHandler) DeletePortfolioByID(c *fiber.Ctx) error { diff --git a/components/ledger/internal/bootstrap/http/product.go b/components/ledger/internal/bootstrap/http/product.go index 18e2a32b..13b90ae2 100644 --- a/components/ledger/internal/bootstrap/http/product.go +++ b/components/ledger/internal/bootstrap/http/product.go @@ -29,7 +29,7 @@ type ProductHandler struct { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param product body mmodel.CreateProductInput true "Product" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Product // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/products [post] func (handler *ProductHandler) CreateProduct(i any, c *fiber.Ctx) error { @@ -76,7 +76,7 @@ func (handler *ProductHandler) CreateProduct(i any, c *fiber.Ctx) error { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param metadata query string false "Metadata" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mpostgres.Pagination{items=[]mmodel.Product} // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/products [get] func (handler *ProductHandler) GetAllProducts(c *fiber.Ctx) error { @@ -147,7 +147,7 @@ func (handler *ProductHandler) GetAllProducts(c *fiber.Ctx) error { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param id path string true "Product ID" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Product // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/products/{id} [get] func (handler *ProductHandler) GetProductByID(c *fiber.Ctx) error { @@ -189,7 +189,7 @@ func (handler *ProductHandler) GetProductByID(c *fiber.Ctx) error { // @Param ledger_id path string true "Ledger ID" // @Param id path string true "Product ID" // @Param product body mmodel.UpdateProductInput true "Product" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 200 {object} mmodel.Product // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/products/{id} [patch] func (handler *ProductHandler) UpdateProduct(i any, c *fiber.Ctx) error { @@ -247,7 +247,7 @@ func (handler *ProductHandler) UpdateProduct(i any, c *fiber.Ctx) error { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // @Param id path string true "Product ID" -// @Param Midaz-Id header string false "Request ID" +// @Param Midaz-Id header string false "Request ID" // @Success 204 // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/products/{id} [delete] func (handler *ProductHandler) DeleteProductByID(c *fiber.Ctx) error { diff --git a/components/transaction/api/docs.go b/components/transaction/api/docs.go index 52409451..d52159b7 100644 --- a/components/transaction/api/docs.go +++ b/components/transaction/api/docs.go @@ -717,20 +717,30 @@ const docTemplate = `{ }, "definitions": { "Amount": { - "description": "Amount structure for marshaling/unmarshalling JSON.", + "description": "Amount is the struct designed to represent the amount of an operation.", "type": "object", + "required": [ + "asset", + "value" + ], "properties": { - "amount": { - "type": "number", - "example": 1500 + "asset": { + "type": "string", + "example": "BRL" }, "scale": { - "type": "number", + "type": "integer", + "minimum": 0, "example": 2 + }, + "value": { + "type": "integer", + "example": 1000 } } }, "AssetRate": { + "description": "AssetRate is a struct designed to store asset rate data.", "type": "object", "properties": { "amount": { @@ -776,7 +786,7 @@ const docTemplate = `{ } }, "Balance": { - "description": "Balance structure for marshaling/unmarshalling JSON.", + "description": "Balance is the struct designed to represent the account balance.", "type": "object", "properties": { "available": { @@ -794,7 +804,7 @@ const docTemplate = `{ } }, "CreateAssetRateInput": { - "description": "CreateAssetRateInput is a struct design to encapsulate payload data.", + "description": "CreateAssetRateInput is the input payload to create an asset rate.", "type": "object", "properties": { "amount": { @@ -824,6 +834,7 @@ const docTemplate = `{ } }, "CreateTransactionInput": { + "description": "CreateTransactionInput is the input payload to create a transaction.", "type": "object", "required": [ "distribute", @@ -843,7 +854,7 @@ const docTemplate = `{ "maxLength": 256 }, "distribute": { - "$ref": "#/definitions/model.Distribute" + "$ref": "#/definitions/Distribute" }, "metadata": { "type": "object", @@ -853,12 +864,66 @@ const docTemplate = `{ "type": "boolean" }, "send": { - "$ref": "#/definitions/model.Send" + "$ref": "#/definitions/Send" + } + } + }, + "Distribute": { + "description": "Distribute is the struct designed to represent the distribution fields of an operation.", + "type": "object", + "required": [ + "to" + ], + "properties": { + "remaining": { + "type": "string" + }, + "to": { + "type": "array", + "items": { + "$ref": "#/definitions/FromTo" + } + } + } + }, + "FromTo": { + "description": "FromTo is the struct designed to represent the from/to fields of an operation.", + "type": "object", + "properties": { + "account": { + "type": "string", + "example": "@person1" + }, + "amount": { + "$ref": "#/definitions/Amount" + }, + "chartOfAccountsG": { + "type": "string", + "example": "1000" + }, + "description": { + "type": "string", + "example": "description" + }, + "isFrom": { + "type": "boolean", + "example": true + }, + "metadata": { + "type": "object", + "additionalProperties": {} + }, + "remaining": { + "type": "string", + "example": "remaining" + }, + "share": { + "$ref": "#/definitions/Share" } } }, "Operation": { - "description": "Operation is a struct designed to encapsulate response payload data.", + "description": "Operation is a struct designed to store operation data.", "type": "object", "properties": { "accountAlias": { @@ -936,7 +1001,7 @@ const docTemplate = `{ } }, "Pagination": { - "description": "Pagination is a struct designed to encapsulate pagination response payload data.", + "description": "Pagination is the struct designed to store the pagination data of an entity list.", "type": "object", "properties": { "items": {}, @@ -950,8 +1015,72 @@ const docTemplate = `{ } } }, + "Send": { + "description": "Send is the struct designed to represent the sending fields of an operation.", + "type": "object", + "required": [ + "asset", + "source", + "value" + ], + "properties": { + "asset": { + "type": "string", + "example": "BRL" + }, + "scale": { + "type": "integer", + "minimum": 0, + "example": 2 + }, + "source": { + "$ref": "#/definitions/Source" + }, + "value": { + "type": "integer", + "example": 1000 + } + } + }, + "Share": { + "description": "Share is the struct designed to represent the sharing fields of an operation.", + "type": "object", + "required": [ + "percentage" + ], + "properties": { + "descWhatever": { + "type": "boolean" + }, + "percentage": { + "type": "integer" + }, + "percentageOfPercentage": { + "type": "integer" + } + } + }, + "Source": { + "description": "Source is the struct designed to represent the source fields of an operation.", + "type": "object", + "required": [ + "from" + ], + "properties": { + "from": { + "type": "array", + "items": { + "$ref": "#/definitions/FromTo" + } + }, + "remaining": { + "type": "string", + "example": "remaining" + } + } + }, "Status": { - "description": "Status structure for marshaling/unmarshalling JSON.", + "description": "Status is the struct designed to represent the status of a transaction.", "type": "object", "properties": { "code": { @@ -967,7 +1096,7 @@ const docTemplate = `{ } }, "Transaction": { - "description": "Transaction is a struct designed to encapsulate response payload data.", + "description": "Transaction is a struct designed to store transaction data.", "type": "object", "properties": { "amount": { @@ -1056,7 +1185,7 @@ const docTemplate = `{ } }, "UpdateOperationInput": { - "description": "UpdateOperationInput is a struct design to encapsulate payload data.", + "description": "UpdateOperationInput is the input payload to update an operation.", "type": "object", "properties": { "description": { @@ -1071,7 +1200,7 @@ const docTemplate = `{ } }, "UpdateTransactionInput": { - "description": "UpdateTransactionInput is a struct design to encapsulate payload data.", + "description": "UpdateTransactionInput is the input payload to update a transaction.", "type": "object", "properties": { "description": { @@ -1084,129 +1213,6 @@ const docTemplate = `{ "additionalProperties": {} } } - }, - "model.Amount": { - "type": "object", - "required": [ - "asset", - "value" - ], - "properties": { - "asset": { - "type": "string" - }, - "scale": { - "type": "integer", - "minimum": 0 - }, - "value": { - "type": "integer" - } - } - }, - "model.Distribute": { - "type": "object", - "required": [ - "to" - ], - "properties": { - "remaining": { - "type": "string" - }, - "to": { - "type": "array", - "items": { - "$ref": "#/definitions/model.FromTo" - } - } - } - }, - "model.FromTo": { - "type": "object", - "properties": { - "account": { - "type": "string" - }, - "amount": { - "$ref": "#/definitions/model.Amount" - }, - "chartOfAccountsG": { - "type": "string" - }, - "description": { - "type": "string" - }, - "isFrom": { - "type": "boolean" - }, - "metadata": { - "type": "object", - "additionalProperties": {} - }, - "remaining": { - "type": "string" - }, - "share": { - "$ref": "#/definitions/model.Share" - } - } - }, - "model.Send": { - "type": "object", - "required": [ - "asset", - "source", - "value" - ], - "properties": { - "asset": { - "type": "string" - }, - "scale": { - "type": "integer", - "minimum": 0 - }, - "source": { - "$ref": "#/definitions/model.Source" - }, - "value": { - "type": "integer" - } - } - }, - "model.Share": { - "type": "object", - "required": [ - "percentage" - ], - "properties": { - "descWhatever": { - "type": "boolean" - }, - "percentage": { - "type": "integer" - }, - "percentageOfPercentage": { - "type": "integer" - } - } - }, - "model.Source": { - "type": "object", - "required": [ - "from" - ], - "properties": { - "from": { - "type": "array", - "items": { - "$ref": "#/definitions/model.FromTo" - } - }, - "remaining": { - "type": "string" - } - } } } }` diff --git a/components/transaction/api/swagger.json b/components/transaction/api/swagger.json index 4d60d1d8..165896f4 100644 --- a/components/transaction/api/swagger.json +++ b/components/transaction/api/swagger.json @@ -711,20 +711,30 @@ }, "definitions": { "Amount": { - "description": "Amount structure for marshaling/unmarshalling JSON.", + "description": "Amount is the struct designed to represent the amount of an operation.", "type": "object", + "required": [ + "asset", + "value" + ], "properties": { - "amount": { - "type": "number", - "example": 1500 + "asset": { + "type": "string", + "example": "BRL" }, "scale": { - "type": "number", + "type": "integer", + "minimum": 0, "example": 2 + }, + "value": { + "type": "integer", + "example": 1000 } } }, "AssetRate": { + "description": "AssetRate is a struct designed to store asset rate data.", "type": "object", "properties": { "amount": { @@ -770,7 +780,7 @@ } }, "Balance": { - "description": "Balance structure for marshaling/unmarshalling JSON.", + "description": "Balance is the struct designed to represent the account balance.", "type": "object", "properties": { "available": { @@ -788,7 +798,7 @@ } }, "CreateAssetRateInput": { - "description": "CreateAssetRateInput is a struct design to encapsulate payload data.", + "description": "CreateAssetRateInput is the input payload to create an asset rate.", "type": "object", "properties": { "amount": { @@ -818,6 +828,7 @@ } }, "CreateTransactionInput": { + "description": "CreateTransactionInput is the input payload to create a transaction.", "type": "object", "required": [ "distribute", @@ -837,7 +848,7 @@ "maxLength": 256 }, "distribute": { - "$ref": "#/definitions/model.Distribute" + "$ref": "#/definitions/Distribute" }, "metadata": { "type": "object", @@ -847,12 +858,66 @@ "type": "boolean" }, "send": { - "$ref": "#/definitions/model.Send" + "$ref": "#/definitions/Send" + } + } + }, + "Distribute": { + "description": "Distribute is the struct designed to represent the distribution fields of an operation.", + "type": "object", + "required": [ + "to" + ], + "properties": { + "remaining": { + "type": "string" + }, + "to": { + "type": "array", + "items": { + "$ref": "#/definitions/FromTo" + } + } + } + }, + "FromTo": { + "description": "FromTo is the struct designed to represent the from/to fields of an operation.", + "type": "object", + "properties": { + "account": { + "type": "string", + "example": "@person1" + }, + "amount": { + "$ref": "#/definitions/Amount" + }, + "chartOfAccountsG": { + "type": "string", + "example": "1000" + }, + "description": { + "type": "string", + "example": "description" + }, + "isFrom": { + "type": "boolean", + "example": true + }, + "metadata": { + "type": "object", + "additionalProperties": {} + }, + "remaining": { + "type": "string", + "example": "remaining" + }, + "share": { + "$ref": "#/definitions/Share" } } }, "Operation": { - "description": "Operation is a struct designed to encapsulate response payload data.", + "description": "Operation is a struct designed to store operation data.", "type": "object", "properties": { "accountAlias": { @@ -930,7 +995,7 @@ } }, "Pagination": { - "description": "Pagination is a struct designed to encapsulate pagination response payload data.", + "description": "Pagination is the struct designed to store the pagination data of an entity list.", "type": "object", "properties": { "items": {}, @@ -944,8 +1009,72 @@ } } }, + "Send": { + "description": "Send is the struct designed to represent the sending fields of an operation.", + "type": "object", + "required": [ + "asset", + "source", + "value" + ], + "properties": { + "asset": { + "type": "string", + "example": "BRL" + }, + "scale": { + "type": "integer", + "minimum": 0, + "example": 2 + }, + "source": { + "$ref": "#/definitions/Source" + }, + "value": { + "type": "integer", + "example": 1000 + } + } + }, + "Share": { + "description": "Share is the struct designed to represent the sharing fields of an operation.", + "type": "object", + "required": [ + "percentage" + ], + "properties": { + "descWhatever": { + "type": "boolean" + }, + "percentage": { + "type": "integer" + }, + "percentageOfPercentage": { + "type": "integer" + } + } + }, + "Source": { + "description": "Source is the struct designed to represent the source fields of an operation.", + "type": "object", + "required": [ + "from" + ], + "properties": { + "from": { + "type": "array", + "items": { + "$ref": "#/definitions/FromTo" + } + }, + "remaining": { + "type": "string", + "example": "remaining" + } + } + }, "Status": { - "description": "Status structure for marshaling/unmarshalling JSON.", + "description": "Status is the struct designed to represent the status of a transaction.", "type": "object", "properties": { "code": { @@ -961,7 +1090,7 @@ } }, "Transaction": { - "description": "Transaction is a struct designed to encapsulate response payload data.", + "description": "Transaction is a struct designed to store transaction data.", "type": "object", "properties": { "amount": { @@ -1050,7 +1179,7 @@ } }, "UpdateOperationInput": { - "description": "UpdateOperationInput is a struct design to encapsulate payload data.", + "description": "UpdateOperationInput is the input payload to update an operation.", "type": "object", "properties": { "description": { @@ -1065,7 +1194,7 @@ } }, "UpdateTransactionInput": { - "description": "UpdateTransactionInput is a struct design to encapsulate payload data.", + "description": "UpdateTransactionInput is the input payload to update a transaction.", "type": "object", "properties": { "description": { @@ -1078,129 +1207,6 @@ "additionalProperties": {} } } - }, - "model.Amount": { - "type": "object", - "required": [ - "asset", - "value" - ], - "properties": { - "asset": { - "type": "string" - }, - "scale": { - "type": "integer", - "minimum": 0 - }, - "value": { - "type": "integer" - } - } - }, - "model.Distribute": { - "type": "object", - "required": [ - "to" - ], - "properties": { - "remaining": { - "type": "string" - }, - "to": { - "type": "array", - "items": { - "$ref": "#/definitions/model.FromTo" - } - } - } - }, - "model.FromTo": { - "type": "object", - "properties": { - "account": { - "type": "string" - }, - "amount": { - "$ref": "#/definitions/model.Amount" - }, - "chartOfAccountsG": { - "type": "string" - }, - "description": { - "type": "string" - }, - "isFrom": { - "type": "boolean" - }, - "metadata": { - "type": "object", - "additionalProperties": {} - }, - "remaining": { - "type": "string" - }, - "share": { - "$ref": "#/definitions/model.Share" - } - } - }, - "model.Send": { - "type": "object", - "required": [ - "asset", - "source", - "value" - ], - "properties": { - "asset": { - "type": "string" - }, - "scale": { - "type": "integer", - "minimum": 0 - }, - "source": { - "$ref": "#/definitions/model.Source" - }, - "value": { - "type": "integer" - } - } - }, - "model.Share": { - "type": "object", - "required": [ - "percentage" - ], - "properties": { - "descWhatever": { - "type": "boolean" - }, - "percentage": { - "type": "integer" - }, - "percentageOfPercentage": { - "type": "integer" - } - } - }, - "model.Source": { - "type": "object", - "required": [ - "from" - ], - "properties": { - "from": { - "type": "array", - "items": { - "$ref": "#/definitions/model.FromTo" - } - }, - "remaining": { - "type": "string" - } - } } } } \ No newline at end of file diff --git a/components/transaction/api/swagger.yaml b/components/transaction/api/swagger.yaml index fe73f40c..dd5593cc 100644 --- a/components/transaction/api/swagger.yaml +++ b/components/transaction/api/swagger.yaml @@ -1,16 +1,24 @@ basePath: / definitions: Amount: - description: Amount structure for marshaling/unmarshalling JSON. + description: Amount is the struct designed to represent the amount of an operation. properties: - amount: - example: 1500 - type: number + asset: + example: BRL + type: string scale: example: 2 - type: number + minimum: 0 + type: integer + value: + example: 1000 + type: integer + required: + - asset + - value type: object AssetRate: + description: AssetRate is a struct designed to store asset rate data. properties: amount: example: 5000 @@ -44,7 +52,7 @@ definitions: type: string type: object Balance: - description: Balance structure for marshaling/unmarshalling JSON. + description: Balance is the struct designed to represent the account balance. properties: available: example: 1500 @@ -57,7 +65,7 @@ definitions: type: number type: object CreateAssetRateInput: - description: CreateAssetRateInput is a struct design to encapsulate payload data. + description: CreateAssetRateInput is the input payload to create an asset rate. properties: amount: example: 5000 @@ -79,6 +87,7 @@ definitions: type: string type: object CreateTransactionInput: + description: CreateTransactionInput is the input payload to create a transaction. properties: chartOfAccountsGroupName: maxLength: 256 @@ -90,20 +99,60 @@ definitions: maxLength: 256 type: string distribute: - $ref: '#/definitions/model.Distribute' + $ref: '#/definitions/Distribute' metadata: additionalProperties: {} type: object pending: type: boolean send: - $ref: '#/definitions/model.Send' + $ref: '#/definitions/Send' required: - distribute - send type: object + Distribute: + description: Distribute is the struct designed to represent the distribution fields + of an operation. + properties: + remaining: + type: string + to: + items: + $ref: '#/definitions/FromTo' + type: array + required: + - to + type: object + FromTo: + description: FromTo is the struct designed to represent the from/to fields of + an operation. + properties: + account: + example: '@person1' + type: string + amount: + $ref: '#/definitions/Amount' + chartOfAccountsG: + example: "1000" + type: string + description: + example: description + type: string + isFrom: + example: true + type: boolean + metadata: + additionalProperties: {} + type: object + remaining: + example: remaining + type: string + share: + $ref: '#/definitions/Share' + type: object Operation: - description: Operation is a struct designed to encapsulate response payload data. + description: Operation is a struct designed to store operation data. properties: accountAlias: example: '@person1' @@ -160,8 +209,8 @@ definitions: type: string type: object Pagination: - description: Pagination is a struct designed to encapsulate pagination response - payload data. + description: Pagination is the struct designed to store the pagination data of + an entity list. properties: items: {} limit: @@ -171,8 +220,56 @@ definitions: example: 1 type: integer type: object + Send: + description: Send is the struct designed to represent the sending fields of an + operation. + properties: + asset: + example: BRL + type: string + scale: + example: 2 + minimum: 0 + type: integer + source: + $ref: '#/definitions/Source' + value: + example: 1000 + type: integer + required: + - asset + - source + - value + type: object + Share: + description: Share is the struct designed to represent the sharing fields of an + operation. + properties: + descWhatever: + type: boolean + percentage: + type: integer + percentageOfPercentage: + type: integer + required: + - percentage + type: object + Source: + description: Source is the struct designed to represent the source fields of an + operation. + properties: + from: + items: + $ref: '#/definitions/FromTo' + type: array + remaining: + example: remaining + type: string + required: + - from + type: object Status: - description: Status structure for marshaling/unmarshalling JSON. + description: Status is the struct designed to represent the status of a transaction. properties: code: example: ACTIVE @@ -184,8 +281,7 @@ definitions: type: string type: object Transaction: - description: Transaction is a struct designed to encapsulate response payload - data. + description: Transaction is a struct designed to store transaction data. properties: amount: example: 1500 @@ -249,7 +345,7 @@ definitions: type: string type: object UpdateOperationInput: - description: UpdateOperationInput is a struct design to encapsulate payload data. + description: UpdateOperationInput is the input payload to update an operation. properties: description: example: Credit card operation @@ -260,8 +356,7 @@ definitions: type: object type: object UpdateTransactionInput: - description: UpdateTransactionInput is a struct design to encapsulate payload - data. + description: UpdateTransactionInput is the input payload to update a transaction. properties: description: example: Transaction description @@ -271,88 +366,6 @@ definitions: additionalProperties: {} type: object type: object - model.Amount: - properties: - asset: - type: string - scale: - minimum: 0 - type: integer - value: - type: integer - required: - - asset - - value - type: object - model.Distribute: - properties: - remaining: - type: string - to: - items: - $ref: '#/definitions/model.FromTo' - type: array - required: - - to - type: object - model.FromTo: - properties: - account: - type: string - amount: - $ref: '#/definitions/model.Amount' - chartOfAccountsG: - type: string - description: - type: string - isFrom: - type: boolean - metadata: - additionalProperties: {} - type: object - remaining: - type: string - share: - $ref: '#/definitions/model.Share' - type: object - model.Send: - properties: - asset: - type: string - scale: - minimum: 0 - type: integer - source: - $ref: '#/definitions/model.Source' - value: - type: integer - required: - - asset - - source - - value - type: object - model.Share: - properties: - descWhatever: - type: boolean - percentage: - type: integer - percentageOfPercentage: - type: integer - required: - - percentage - type: object - model.Source: - properties: - from: - items: - $ref: '#/definitions/model.FromTo' - type: array - remaining: - type: string - required: - - from - type: object host: localhost:3002 info: contact: diff --git a/components/transaction/internal/adapters/database/postgres/assetrate/assetrate.go b/components/transaction/internal/adapters/database/postgres/assetrate/assetrate.go index 92f0aec3..a0d213ee 100644 --- a/components/transaction/internal/adapters/database/postgres/assetrate/assetrate.go +++ b/components/transaction/internal/adapters/database/postgres/assetrate/assetrate.go @@ -22,7 +22,7 @@ type AssetRatePostgreSQLModel struct { // CreateAssetRateInput is a struct design to encapsulate payload data. // // swagger:model CreateAssetRateInput -// @Description CreateAssetRateInput is a struct design to encapsulate payload data. +// @Description CreateAssetRateInput is the input payload to create an asset rate. type CreateAssetRateInput struct { BaseAssetCode string `json:"baseAssetCode" example:"BRL"` CounterAssetCode string `json:"counterAssetCode" example:"USD"` @@ -35,7 +35,7 @@ type CreateAssetRateInput struct { // AssetRate is a struct designed to encapsulate response payload data. // // swagger:model AssetRate - +// @Description AssetRate is a struct designed to store asset rate data. type AssetRate struct { ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"` BaseAssetCode string `json:"baseAssetCode" example:"BRL"` diff --git a/components/transaction/internal/adapters/database/postgres/operation/operation.go b/components/transaction/internal/adapters/database/postgres/operation/operation.go index 84159530..f09e4dce 100644 --- a/components/transaction/internal/adapters/database/postgres/operation/operation.go +++ b/components/transaction/internal/adapters/database/postgres/operation/operation.go @@ -38,7 +38,7 @@ type OperationPostgreSQLModel struct { // Status structure for marshaling/unmarshalling JSON. // // swagger:model Status -// @Description Status structure for marshaling/unmarshalling JSON. +// @Description Status is the struct designed to represent the status of an operation. type Status struct { Code string `json:"code" validate:"max=100" example:"ACTIVE"` Description *string `json:"description" validate:"omitempty,max=256" example:"Active status"` @@ -52,7 +52,7 @@ func (s Status) IsEmpty() bool { // Amount structure for marshaling/unmarshalling JSON. // // swagger:model Amount -// @Description Amount structure for marshaling/unmarshalling JSON. +// @Description Amount is the struct designed to represent the amount of an operation. type Amount struct { Amount *float64 `json:"amount" example:"1500"` Scale *float64 `json:"scale" example:"2"` @@ -66,7 +66,7 @@ func (a Amount) IsEmpty() bool { // Balance structure for marshaling/unmarshalling JSON. // // swagger:model Balance -// @Description Balance structure for marshaling/unmarshalling JSON. +// @Description Balance is the struct designed to represent the account balance. type Balance struct { Available *float64 `json:"available" example:"1500"` OnHold *float64 `json:"onHold" example:"500"` @@ -81,7 +81,7 @@ func (b Balance) IsEmpty() bool { // Operation is a struct designed to encapsulate response payload data. // // swagger:model Operation -// @Description Operation is a struct designed to encapsulate response payload data. +// @Description Operation is a struct designed to store operation data. type Operation struct { ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"` TransactionID string `json:"transactionId" example:"00000000-0000-0000-0000-000000000000"` @@ -101,7 +101,7 @@ type Operation struct { CreatedAt time.Time `json:"createdAt" example:"2021-01-01T00:00:00Z"` UpdatedAt time.Time `json:"updatedAt" example:"2021-01-01T00:00:00Z"` DeletedAt *time.Time `json:"deletedAt" example:"2021-01-01T00:00:00Z"` - Metadata map[string]any `json:"metadata" example:map[string]any{"key": "value"}` + Metadata map[string]any `json:"metadata"` } // @name Operation // ToEntity converts an OperationPostgreSQLModel to entity Operation @@ -198,7 +198,7 @@ func (t *OperationPostgreSQLModel) FromEntity(operation *Operation) { // UpdateOperationInput is a struct design to encapsulate payload data. // // swagger:model UpdateOperationInput -// @Description UpdateOperationInput is a struct design to encapsulate payload data. +// @Description UpdateOperationInput is the input payload to update an operation. type UpdateOperationInput struct { Description string `json:"description" validate:"max=256" example:"Credit card operation"` Metadata map[string]any `json:"metadata,omitempty"` diff --git a/components/transaction/internal/adapters/database/postgres/transaction/transaction.go b/components/transaction/internal/adapters/database/postgres/transaction/transaction.go index 4fa1f1c3..6487dc8d 100644 --- a/components/transaction/internal/adapters/database/postgres/transaction/transaction.go +++ b/components/transaction/internal/adapters/database/postgres/transaction/transaction.go @@ -33,7 +33,7 @@ type TransactionPostgreSQLModel struct { // Status structure for marshaling/unmarshalling JSON. // // swagger:model Status -// @Description Status structure for marshaling/unmarshalling JSON. +// @Description Status is the struct designed to represent the status of a transaction. type Status struct { Code string `json:"code" validate:"max=100" example:"ACTIVE"` Description *string `json:"description" validate:"omitempty,max=256" example:"Active status"` @@ -44,7 +44,10 @@ func (s Status) IsEmpty() bool { return s.Code == "" && s.Description == nil } -// CreateTransactionInput is a struct design to encapsulate payload data. +// CreateTransactionInput is a struct design to encapsulate payload data. +// +// swagger:model CreateTransactionInput +// @Description CreateTransactionInput is the input payload to create a transaction. type CreateTransactionInput struct { ChartOfAccountsGroupName string `json:"chartOfAccountsGroupName,omitempty" validate:"max=256"` Description string `json:"description,omitempty" validate:"max=256"` @@ -65,7 +68,7 @@ type InputDSL struct { // UpdateTransactionInput is a struct design to encapsulate payload data. // // swagger:model UpdateTransactionInput -// @Description UpdateTransactionInput is a struct design to encapsulate payload data. +// @Description UpdateTransactionInput is the input payload to update a transaction. type UpdateTransactionInput struct { Description string `json:"description" validate:"max=256" example:"Transaction description"` Metadata map[string]any `json:"metadata,omitempty"` @@ -74,7 +77,7 @@ type UpdateTransactionInput struct { // Transaction is a struct designed to encapsulate response payload data. // // swagger:model Transaction -// @Description Transaction is a struct designed to encapsulate response payload data. +// @Description Transaction is a struct designed to store transaction data. type Transaction struct { ID string `json:"id" example:"00000000-0000-0000-0000-000000000000"` ParentTransactionID *string `json:"parentTransactionId,omitempty" example:"00000000-0000-0000-0000-000000000000"` diff --git a/components/transaction/internal/bootstrap/http/assetrate.go b/components/transaction/internal/bootstrap/http/assetrate.go index 6869a2e8..6fe460f5 100644 --- a/components/transaction/internal/bootstrap/http/assetrate.go +++ b/components/transaction/internal/bootstrap/http/assetrate.go @@ -25,12 +25,12 @@ type AssetRateHandler struct { // @Accept json // @Produce json // -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" // -// @Param asset-rate body ar.CreateAssetRateInput true "AssetRate Input" +// @Param asset-rate body assetrate.CreateAssetRateInput true "AssetRate Input" // @Param Midaz-Id header string false "Request ID" -// @Success 200 {object} ar.AssetRate +// @Success 200 {object} assetrate.AssetRate // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/asset-rates [post] func (handler *AssetRateHandler) CreateAssetRate(p any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -78,13 +78,13 @@ func (handler *AssetRateHandler) CreateAssetRate(p any, c *fiber.Ctx) error { // @Tags Asset Rates // @Produce json // -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param asset_rate_id path string true "AssetRate ID" +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param asset_rate_id path string true "AssetRate ID" // -// @Param asset-rate body ar.CreateAssetRateInput true "AssetRate Input" +// @Param asset-rate body assetrate.CreateAssetRateInput true "AssetRate Input" // @Param Midaz-Id header string false "Request ID" -// @Success 200 {object} ar.AssetRate +// @Success 200 {object} assetrate.AssetRate // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/asset-rates/{asset_rate_id} [get] func (handler *AssetRateHandler) GetAssetRate(c *fiber.Ctx) error { ctx := c.UserContext() diff --git a/components/transaction/internal/bootstrap/http/operation.go b/components/transaction/internal/bootstrap/http/operation.go index e1545c46..4ab9328f 100644 --- a/components/transaction/internal/bootstrap/http/operation.go +++ b/components/transaction/internal/bootstrap/http/operation.go @@ -30,8 +30,8 @@ type OperationHandler struct { // @Param ledger_id path string true "Ledger ID" // // @Param account_id path string true "Account ID" -// @Param Midaz-Id header string false "Request ID" -// @Success 200 {object} mpostgres.Pagination{items=[]o.Operation} +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mpostgres.Pagination{items=[]operation.Operation} // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{account_id}/operations [get] func (handler *OperationHandler) GetAllOperationsByAccount(c *fiber.Ctx) error { ctx := c.UserContext() @@ -92,8 +92,8 @@ func (handler *OperationHandler) GetAllOperationsByAccount(c *fiber.Ctx) error { // // @Param account_id path string true "Account ID" // @Param operation_id path string true "Operation ID" -// @Param Midaz-Id header string false "Request ID" -// @Success 200 {object} o.Operation +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} operation.Operation // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{account_id}/operations/{operation_id} [get] func (handler *OperationHandler) GetOperationByAccount(c *fiber.Ctx) error { ctx := c.UserContext() @@ -136,8 +136,8 @@ func (handler *OperationHandler) GetOperationByAccount(c *fiber.Ctx) error { // @Param ledger_id path string true "Ledger ID" // // @Param portfolio_id path string true "Portfolio ID" -// @Param Midaz-Id header string false "Request ID" -// @Success 200 {object} mpostgres.Pagination{items=[]o.Operation} +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mpostgres.Pagination{items=[]operation.Operation} // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/operations [get] func (handler *OperationHandler) GetAllOperationsByPortfolio(c *fiber.Ctx) error { ctx := c.UserContext() @@ -198,8 +198,8 @@ func (handler *OperationHandler) GetAllOperationsByPortfolio(c *fiber.Ctx) error // // @Param portfolio_id path string true "Portfolio ID" // @Param operation_id path string true "Operation ID" -// @Param Midaz-Id header string false "Request ID" -// @Success 200 {object} o.Operation +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} operation.Operation // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/portfolios/{portfolio_id}/operations/{operation_id} [get] func (handler *OperationHandler) GetOperationByPortfolio(c *fiber.Ctx) error { ctx := c.UserContext() @@ -239,14 +239,14 @@ func (handler *OperationHandler) GetOperationByPortfolio(c *fiber.Ctx) error { // @Accept json // @Produce json // -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param transaction_id path string true "Transaction ID" -// @Param operation_id path string true "Operation ID" +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param transaction_id path string true "Transaction ID" +// @Param operation_id path string true "Operation ID" // -// @Param operation body o.UpdateOperationInput true "Operation Input" +// @Param operation body operation.UpdateOperationInput true "Operation Input" // @Param Midaz-Id header string false "Request ID" -// @Success 200 {object} o.Operation +// @Success 200 {object} operation.Operation // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/{transaction_id}/operations/{operation_id} [patch] func (handler *OperationHandler) UpdateOperation(p any, c *fiber.Ctx) error { ctx := c.UserContext() diff --git a/components/transaction/internal/bootstrap/http/transaction.go b/components/transaction/internal/bootstrap/http/transaction.go index 4f55d9dc..9d6121f4 100644 --- a/components/transaction/internal/bootstrap/http/transaction.go +++ b/components/transaction/internal/bootstrap/http/transaction.go @@ -37,12 +37,12 @@ type TransactionHandler struct { // @Accept json // @Produce json // -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" // -// @Param transaction body t.CreateTransactionInput true "Transaction Input" -// @Param Midaz-Id header string false "Request ID" -// @Success 200 {object} t.Transaction +// @Param transaction body transaction.CreateTransactionInput true "Transaction Input" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} transaction.Transaction // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/json [post] func (handler *TransactionHandler) CreateTransactionJSON(p any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -76,8 +76,8 @@ func (handler *TransactionHandler) CreateTransactionJSON(p any, c *fiber.Ctx) er // @Param ledger_id path string true "Ledger ID" // // @Param transaction formData file true "Transaction DSL file" -// @Param Midaz-Id header string false "Request ID" -// @Success 200 {object} t.Transaction +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} transaction.Transaction // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/dsl [post] func (handler *TransactionHandler) CreateTransactionDSL(c *fiber.Ctx) error { ctx := c.UserContext() @@ -181,13 +181,13 @@ func (handler *TransactionHandler) RevertTransaction(c *fiber.Ctx) error { // @Accept json // @Produce json // -// @Param organization_id path string true "Organization ID" -// @Param ledger_id path string true "Ledger ID" -// @Param transaction_id path string true "Transaction ID" +// @Param organization_id path string true "Organization ID" +// @Param ledger_id path string true "Ledger ID" +// @Param transaction_id path string true "Transaction ID" // -// @Param transaction body t.UpdateTransactionInput true "Transaction Input" -// @Param Midaz-Id header string false "Request ID" -// @Success 200 {object} t.Transaction +// @Param transaction body transaction.UpdateTransactionInput true "Transaction Input" +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} transaction.Transaction // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/{transaction_id} [patch] func (handler *TransactionHandler) UpdateTransaction(p any, c *fiber.Ctx) error { ctx := c.UserContext() @@ -241,8 +241,8 @@ func (handler *TransactionHandler) UpdateTransaction(p any, c *fiber.Ctx) error // @Param ledger_id path string true "Ledger ID" // @Param transaction_id path string true "Transaction ID" // -// @Param Midaz-Id header string false "Request ID" -// @Success 200 {object} t.Transaction +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} transaction.Transaction // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions/{transaction_id} [get] func (handler *TransactionHandler) GetTransaction(c *fiber.Ctx) error { ctx := c.UserContext() @@ -281,8 +281,8 @@ func (handler *TransactionHandler) GetTransaction(c *fiber.Ctx) error { // @Param organization_id path string true "Organization ID" // @Param ledger_id path string true "Ledger ID" // -// @Param Midaz-Id header string false "Request ID" -// @Success 200 {object} mpostgres.Pagination{items=[]t.Transaction} +// @Param Midaz-Id header string false "Request ID" +// @Success 200 {object} mpostgres.Pagination{items=[]transaction.Transaction} // @Router /v1/organizations/{organization_id}/ledgers/{ledger_id}/transactions [get] func (handler *TransactionHandler) GetAllTransactions(c *fiber.Ctx) error { ctx := c.UserContext()