-
Notifications
You must be signed in to change notification settings - Fork 0
/
swagger.yaml
354 lines (354 loc) · 7.87 KB
/
swagger.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
basePath: /
definitions:
api.CreateAccountRequest:
properties:
currency:
type: string
required:
- currency
type: object
api.loginUserResponse:
properties:
access_token:
type: string
user:
$ref: '#/definitions/api.userResponse'
type: object
type: object
api.userResponse:
properties:
created_at:
type: string
email:
type: string
full_name:
type: string
password_changed_at:
type: string
username:
type: string
type: object
db.Account:
properties:
balance:
type: integer
created_at:
type: string
currency:
type: string
id:
type: integer
owner:
type: string
type: object
db.Entry:
properties:
account_id:
type: integer
amount:
description: can be negative or positive
type: integer
created_at:
type: string
id:
type: integer
type: object
db.Transfer:
properties:
amount:
description: must be positive
type: integer
created_at:
type: string
from_account_id:
type: integer
id:
type: integer
to_account_id:
type: integer
type: object
db.TransferTxResult:
properties:
from_account:
$ref: '#/definitions/db.Account'
type: object
from_entry:
$ref: '#/definitions/db.Entry'
type: object
to_account:
$ref: '#/definitions/db.Account'
type: object
to_entry:
$ref: '#/definitions/db.Entry'
type: object
transfer:
$ref: '#/definitions/db.Transfer'
type: object
type: object
gin.H:
additionalProperties: true
type: object
host: localhost:8080
info:
contact:
email: [email protected]
name: API Support
url: https://github.com/hhow09/simple_bank/issues
description: A simple bank service.
license: {}
title: Simple Bank API
version: "1.0"
paths:
/accounts:
get:
consumes:
- application/json
description: list account under current user
parameters:
- description: page id minimum(1)
in: query
name: page_id
required: true
type: integer
- description: page minimum(5) maximum(10)
in: query
name: page_size
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/db.Account'
type: array
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"403":
description: Forbidden
schema:
$ref: '#/definitions/gin.H'
security:
- authorization: []
summary: list Account
tags:
- accounts
post:
consumes:
- application/json
description: create account by a already-login user
parameters:
- description: currency
in: body
name: currency
required: true
schema:
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/api.CreateAccountRequest'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"403":
description: Forbidden
schema:
$ref: '#/definitions/gin.H'
security:
- authorization: []
summary: Create Account
tags:
- accounts
/accounts/:id:
get:
consumes:
- application/json
description: get account by account id
parameters:
- description: Account ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/db.Account'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"403":
description: Forbidden
schema:
$ref: '#/definitions/gin.H'
security:
- authorization: []
summary: get Account
tags:
- accounts
/transfers:
post:
consumes:
- application/json
description: Create transfer from from_account_id to to_account_id which has
same currency
parameters:
- description: from_account_id
in: body
name: from_account_id
required: true
schema:
type: integer
- description: to_account_id
in: body
name: to_account_id
required: true
schema:
type: integer
- description: amount
in: body
name: amount
required: true
schema:
type: integer
- description: currency
in: body
name: currency
required: true
schema:
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/db.TransferTxResult'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"403":
description: Forbidden
schema:
$ref: '#/definitions/gin.H'
security:
- authorization: []
summary: Create Transfer
tags:
- transfers
/users:
post:
consumes:
- application/json
description: Create User by json user params
parameters:
- description: user name
in: body
name: username
required: true
schema:
type: string
- description: passward minLength(6)
in: body
minLength: 6
name: password
required: true
schema:
type: string
- description: full name
in: body
name: fullname
required: true
schema:
type: string
- description: email
in: body
name: email
required: true
schema:
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/api.userResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
summary: Create a User
tags:
- users
/users/login:
post:
consumes:
- application/json
description: Login with username and password
parameters:
- description: user name
in: body
name: username
required: true
schema:
type: string
- description: passward minLength(6)
in: body
minLength: 6
name: password
required: true
schema:
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/api.loginUserResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/gin.H'
"404":
description: Not Found
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
summary: User Login
tags:
- users
securityDefinitions:
BasicAuth:
type: basic
authorization:
in: header
name: Authorization
type: apiKey
swagger: "2.0"