-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathOpenAPI.yml
355 lines (346 loc) · 10.1 KB
/
OpenAPI.yml
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
355
openapi: 3.0.0
# Added by API Auto Mocking Plugin
servers:
# Added by API Auto Mocking Plugin
- description: SwaggerHub API Auto Mocking
url: https://virtserver.swaggerhub.com/BlueBash/TinyURI/1.0.0
- description: SwaggerHub API Auto Mocking
url: https://virtserver.swaggerhub.com/Melic93/TinyURI/1.0.0
info:
description: This is a URI Shorter API
version: "1.0.0"
title: TinyURI
contact:
email: [email protected]
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
tags:
- name: F0
description: |
The app will short, storage and get URI's
* When the user creates the URI with `POST /uri` the system will save the URI and its hash in the DB.
* When the user requests `GET /uri/{id}` the system will redirect to the original URI stored in the DB whose hash is {id}
* When the user requests `DELETE /uri/{id}` the system will delete the original URI and its hash from the DB
- name: F1
description: |
The app will return system stats and info. (WS)
* When the user creates the URI with `POST /uri` the system will update the stat of URI's created
* When the user requests `GET /stats`, the system will return the number of URI´s created, the number of URI´s alive when the request is made and the number of requests received.
* When the user requests `GET /stats/{id}` the system will return stats from the URI linked to the id. Those stats are the number of requests received to that URI, the time the last request was made and the date of creation.
- name: F2
description: |
The app will limit the number of redirections
* When the user requests `GET /uri/{id}` the system will check that the number of requests to that URI in the last minute is lower than a defined constant **MAX_REDIRECT**.
- name: F3
description: |
The app will let the user choose and update a name for the shorted URI
* When the user requests `POST /uri/{name}`the system will create a `{name}` associated and will store it in DB
* When the user requests `PUT /uri/{name}` the system will update the associated `{name}` of the URI
- name: F4
description: |
The app will create a QR associated with that URI
* When the user requests `POST /uri` the system will create a QR code associated to that URI, will encode it in base64 and store it in DB
* When the user requests `GET /qr/{id}` the system will return the associated QR image stored in DB
* When the user requests `GET /qr/{id}` with any query parameter, the system will generate a new QR code for that id, personalised with the parameter specified in the query and will retrun it without storing it in the DB
- name: F5
description: |
The app will verify periodically that the shorthed URI is alive
* When the user creates the URI with `POST /uri` the user might request that this URI is alive
* When the user requests `GET /uri/{id}` if it's being checked and it isn't alive, it will return an error
* When the user or the system requests `GET /check/{id}` the system will return if the URI is alive
paths:
/uri:
post:
tags:
- F0
- F1
- F4
- F5
summary: Creates a new redirection
operationId: createURI
description: |
Create a new URI redirection
requestBody:
description: URI
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/URICreate'
responses:
'201':
description: The URI redirection has been successfully created
content:
application/json:
schema:
$ref: '#/components/schemas/URIItem'
/uri/{id}:
get:
tags:
- F0
- F2
- F5
summary: Returns the data of a redirection
operationId: getURI
description: |
Get a URI redirection
parameters:
- in: path
name: id
required: true
schema:
type: string
responses:
'307':
description: Redirect to the real URI
'404':
description: The given URI couldn't be found
delete:
tags:
- F0
summary: Deletes an existing URI and its content.
operationId: deleteURI
description: |
Remove a URI redirection
parameters:
- in: path
name: id
required: true
schema:
type: string
- in: query
name: hashpass
required: true
schema:
type: string
responses:
'200':
description: Resource has been removed successfully
'404':
description: There is no URI with that hash
/stats:
get:
tags:
- F1
summary: Returns stats from server
operationId: getStats
description: |
Get stats info
responses:
'200':
description: Stats from server
content:
application/json:
schema:
$ref: '#/components/schemas/Stats'
/stats/{id}:
get:
tags:
- F1
summary: Returns stats from server
operationId: getStats
description: |
Get stats info
responses:
'200':
description: Stats from server
content:
application/json:
schema:
$ref: '#/components/schemas/Stats'
parameters:
- in: path
name: id
required: true
schema:
type: string
/uri/{name}:
post:
tags:
- F3
summary: Creates a name of a redirection
operationId: changeURI
description:
Assigns the name of a redirection
requestBody:
description: Optional description in *Markdown*
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/URICreate'
parameters:
- in: path
name: name
required: true
schema:
type: string
responses:
'201':
description: Name has been assigned successfully
content:
application/json:
schema:
$ref: '#/components/schemas/URIItem'
'400':
description: Error creating resource
put:
tags:
- F3
summary: Assigns the name of a redirection
operationId: changeURI
description:
Assigns the name of a redirection
requestBody:
description: Optional description in *Markdown*
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/URIUpdate'
parameters:
- in: path
name: name
required: true
schema:
type: string
responses:
'200':
description: Name has been assigned successfully
content:
application/json:
schema:
$ref: '#/components/schemas/URIItem'
'400':
description: Error creating resource
/qr/{id}:
get:
tags:
- F4
summary: Obtains the QR and the URI associated to a shortened URI
operationId: getQR
description:
Obtains the QR and the URI associated to a shortened URI
parameters:
- in: path
name: id
required: true
schema:
type: string
- in: query
name: width
required: false
schema:
type: integer
- in: query
name: height
required: false
schema:
type: integer
responses:
'200':
description: QR and original URI
content:
application/json:
schema:
$ref: '#/components/schemas/QRItem'
'404':
description: the shortened URI doesn't exist
/check/{id}:
get:
tags:
- F5
summary: Checks the state of the original URI
operationId: checkURI
description:
Checks the state of the original URI
parameters:
- in: path
name: id
required: true
schema:
type: string
responses:
'200':
description: The original URI is alive
'404':
description: The original URI is dead or the shortened URI doesn't exist
components:
schemas:
QRItem:
type: object
required:
- uri
- qr
properties:
uri:
type: string
format: hash
example: d290f1ee6c
qr:
type: string
format: base64
URIItem:
type: object
required:
- id
- redirection
- hashpass
properties:
id:
type: string
example: d290f1ee6c
redirection:
type: string
format: uri
example: https://google.es/
hashpass:
type: string
example: adsgv674fjhag
URICreate:
type: object
required:
- uri
properties:
uri:
type: string
format: uri
example: https://google.es/
URIUpdate:
type: object
required:
- uri
properties:
new-name:
type: string
format: string
example: newname4
hashpass:
type: string
format: string
example: skljdhgks
Stats:
type: object
required:
- redirected-uris
- server-load
- generated-qr
properties:
redirected-uris:
type: integer
example: 3457
server-load:
type: number
example: 0.79
generated-qr:
type: integer
example: 1243
ErrorItem:
type: object
required:
- error-info
properties:
error-info:
type: string
example: "Error creating shorthed URI. Resource is already in use"