/
openapi.yaml
87 lines (87 loc) · 2.36 KB
/
openapi.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
openapi: 3.0.0
info:
title: URL Shortening Service
description: Service to shorten long URLs.
version: 1.0.0
servers:
- url: https://example.com/
paths:
/shorten:
post:
summary: Shorten a URL
operationId: shorty.shorten_url
requestBody:
description: URL to shorten
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Url'
examples:
shortenUrlRequest:
value:
url: "https://www.very-long-url.com/"
responses:
'200':
description: Short URL
content:
application/json:
schema:
$ref: '#/components/schemas/Url'
examples:
shortenUrlResponse:
value:
url: "https://example.com/abc123"
'400':
description: Invalid URL provided
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
examples:
invalidUrlResponse:
value:
error: "Invalid URL provided"
/{short_code}:
get:
summary: Redirect to long URL
operationId: shorty.redirect_to_url
parameters:
- name: short_code
in: path
required: true
schema:
type: string
responses:
'302':
description: Redirect to the long URL
headers:
Location:
description: The long URL to redirect to
schema:
type: string
format: uri
'404':
description: Short URL not found or expired
content:
text/html:
schema:
type: string
examples:
notFoundResponse:
value: "<html><head><title>URL Not Found</title></head><body><h1>URL Not Found</h1><p>The URL you have requested could not be found. Please check the URL and try again.</p></body></html>"
components:
schemas:
Url:
type: object
properties:
url:
type: string
format: uri
description: The URL
Error:
type: object
properties:
error:
type: string
description: The error message