Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1c7bc3a

Browse files
committedDec 25, 2019
add api.md
1 parent 9a43827 commit 1c7bc3a

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed
 

‎docs/api.md

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Swagger Golang REST API demo
2+
This is a sample API server
3+
4+
## Version: 1.0.0
5+
6+
7+
### /accounts
8+
9+
#### POST
10+
##### Summary:
11+
12+
Add a new account
13+
14+
##### Parameters
15+
16+
| Name | Located in | Description | Required | Schema |
17+
| ---- | ---------- | ----------- | -------- | ---- |
18+
| body | body | Account object that needs to be added to the store | Yes | [AccountRequest](#accountrequest) |
19+
20+
##### Responses
21+
22+
| Code | Description | Schema |
23+
| ---- | ----------- | ------ |
24+
| 200 | OK | [AccountResponce](#accountresponce) |
25+
| 400 | invalid input: cannot decode | |
26+
27+
#### GET
28+
##### Summary:
29+
30+
Get all accounts
31+
32+
##### Responses
33+
34+
| Code | Description | Schema |
35+
| ---- | ----------- | ------ |
36+
| 200 | OK | [ [AccountResponce](#accountresponce) ] |
37+
| 500 | internal server error | |
38+
39+
### /accounts/{accountId}/payments
40+
41+
#### GET
42+
##### Summary:
43+
44+
Get account payments
45+
46+
##### Parameters
47+
48+
| Name | Located in | Description | Required | Schema |
49+
| ---- | ---------- | ----------- | -------- | ---- |
50+
| accountId | path | ID of account | Yes | int64 |
51+
52+
##### Responses
53+
54+
| Code | Description | Schema |
55+
| ---- | ----------- | ------ |
56+
| 200 | OK | [ [AccountPaymentResponse](#accountpaymentresponse) ] |
57+
| 500 | internal server error | |
58+
59+
### /payments
60+
61+
#### POST
62+
##### Summary:
63+
64+
Do a new payment
65+
66+
##### Parameters
67+
68+
| Name | Located in | Description | Required | Schema |
69+
| ---- | ---------- | ----------- | -------- | ---- |
70+
| body | body | Payment object that needs to be added to the store | Yes | [DoPaymentRquest](#dopaymentrquest) |
71+
72+
##### Responses
73+
74+
| Code | Description | Schema |
75+
| ---- | ----------- | ------ |
76+
| 200 | OK | [AccountResponce](#accountresponce) |
77+
| 400 | invalid input: cannot decode | |
78+
79+
### Models
80+
81+
82+
#### AccountRequest
83+
84+
| Name | Type | Description | Required |
85+
| ---- | ---- | ----------- | -------- |
86+
| name | string | the new account name | Yes |
87+
| currency | string | the account currency | Yes |
88+
| balance | int64 | the account initial balance | Yes |
89+
90+
#### AccountResponce
91+
92+
| Name | Type | Description | Required |
93+
| ---- | ---- | ----------- | -------- |
94+
| id | int64 | the account ID | Yes |
95+
| name | string | | Yes |
96+
| currency | string | | Yes |
97+
| balance | int64 | | Yes |
98+
99+
#### DoPaymentRquest
100+
101+
| Name | Type | Description | Required |
102+
| ---- | ---- | ----------- | -------- |
103+
| amount | int64 | how much money need to transfer | Yes |
104+
| to_id | string | transfer to account ID | Yes |
105+
| from_id | string | transfer from account ID | Yes |
106+
107+
#### AccountPaymentResponse
108+
109+
| Name | Type | Description | Required |
110+
| ---- | ---- | ----------- | -------- |
111+
| id | int64 | the payment ID | Yes |
112+
| amount | int64 | how much money transferred | Yes |
113+
| to_account | string | transferred to account ID | Yes |
114+
| from_account | string | transferred from account ID | Yes |
115+
| direction | string | transfer direction | Yes |

0 commit comments

Comments
 (0)
Please sign in to comment.