-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswagger.yml
More file actions
108 lines (102 loc) · 2.42 KB
/
swagger.yml
File metadata and controls
108 lines (102 loc) · 2.42 KB
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
swagger: "2.0"
info:
title: "Urlshortener"
version: "0.0.1"
basePath: "/v1"
definitions:
InternalError:
type: object
properties:
common:
type: string
example: "Something went wrong"
ValidationError:
type: object
additionalProperties:
type: string
NotFoundError:
type: object
description: "Not found"
properties:
common:
type: string
example: "Link is not found"
SourceLink:
type: object
description: "Source URL"
required:
- long_url
properties:
long_url:
type: string
format: url
ShortLink:
type: object
description: "Short URL"
properties:
long_url:
type: string
format: url
short_url:
type: string
format: url
RedirectURL:
type: object
description: "URL for redirection"
properties:
long_url:
type: string
format: url
paths:
/shrink:
post:
summary: "Creates a short URL from a long URL"
parameters:
- in: body
name: body
required: true
schema:
$ref: "#/definitions/SourceLink"
responses:
200:
description: "Short URL successfully created"
schema:
$ref: "#/definitions/ShortLink"
400:
description: "Validation error"
schema:
$ref: "#/definitions/ValidationError"
500:
description: "Internal error"
schema:
$ref: "#/definitions/InternalError"
/{shortCode}:
get:
summary: "Represents a short URL. Tracks the visit and redirects to the corresponding long URL"
parameters:
- in: "path"
name: "shortCode"
description: "The short code to resolve"
required: true
type: "string"
- in: "header"
name: "user_agent"
required: false
type: "string"
responses:
302:
description: "Visit properly tracked and redirected"
headers:
Location:
type: string
description: "Redirect url"
schema:
$ref: "#/definitions/RedirectURL"
404:
description: "Session is not found"
schema:
$ref: "#/definitions/NotFoundError"
500:
description: "Internal error"
schema:
$ref: "#/definitions/InternalError"