Swagger Golang REST API demo

December 25, 2019 ยท View on GitHub

This is a sample API server

Version: 1.0.0

/accounts

POST

Summary:

Add a new account

Parameters
NameLocated inDescriptionRequiredSchema
bodybodyAccount object that needs to be added to the storeYesAccountRequest
Responses
CodeDescriptionSchema
200OKAccountResponce
400invalid input: cannot decode

GET

Summary:

Get all accounts

Responses
CodeDescriptionSchema
200OK[ AccountResponce ]
500internal server error

/accounts/{accountId}/payments

GET

Summary:

Get account payments

Parameters
NameLocated inDescriptionRequiredSchema
accountIdpathID of accountYesint64
Responses
CodeDescriptionSchema
200OK[ AccountPaymentResponse ]
500internal server error

/payments

POST

Summary:

Do a new payment

Parameters
NameLocated inDescriptionRequiredSchema
bodybodyPayment object that needs to be added to the storeYesDoPaymentRquest
Responses
CodeDescriptionSchema
200OKAccountResponce
400invalid input: cannot decode

Models

AccountRequest

NameTypeDescriptionRequired
namestringthe new account nameYes
currencystringthe account currencyYes
balanceint64the account initial balanceYes

AccountResponce

NameTypeDescriptionRequired
idint64the account IDYes
namestringYes
currencystringYes
balanceint64Yes

DoPaymentRquest

NameTypeDescriptionRequired
amountint64how much money need to transferYes
to_idstringtransfer to account IDYes
from_idstringtransfer from account IDYes

AccountPaymentResponse

NameTypeDescriptionRequired
idint64the payment IDYes
amountint64how much money transferredYes
to_accountstringtransferred to account IDYes
from_accountstringtransferred from account IDYes
directionstringtransfer directionYes