-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopenapi.yaml
126 lines (124 loc) · 3.21 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
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
openapi: '3.0.0'
info:
version: 1.0.0
title: Shorten URLs
license:
name: MIT
contact:
email: [email protected]
servers:
- url: https://shorten.msroed.io/v1
tags:
- name: shorten
paths:
/:
post:
summary: Create a shortened URL
operationId: createShortenedURL
tags:
- shorten
requestBody:
required: true
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/ShortenRequest'
responses:
200:
description: Success
content:
application/json; charset=utf-8:
schema:
$ref: '#/components/schemas/ShortenResponse'
400:
description: Bad request format
content:
application/json; charset=utf-8:
schema:
type: object
properties:
message:
type: string
example: { 'message': 'Please send a valid URL' }
409:
description: Slug already taken
content:
application/json; charset=utf-8:
schema:
type: object
properties:
message:
type: string
example: { 'message': 'hello-world is already taken.' }
/{slug}:
get:
summary: Resolve a slug
operationId: resolveSlug
description: Redirects to the url determined by the slug. Can respond with json if `noresponse` is set.
tags:
- shorten
parameters:
- name: slug
in: path
required: true
description: The slug of the shortened url
schema:
type: string
example: foo-bar
- name: noredirect
in: query
description: Do not redirect, show json instead.
required: false
schema:
type: boolean
default: false
example: false
responses:
200:
description: Success
content:
application/json; charset=utf-8:
schema:
type: object
properties:
redirectUrl:
type: string
example: { redirectUrl: 'https://some-obscure-url.com' }
302:
description: 'Redirect'
404:
$ref: '#/components/responses/NotFound'
components:
responses:
NotFound:
description: This is not found
content:
application/json; charset=utf-8:
schema:
type: object
properties:
message:
type: string
example:
{ 'message': 'Can not find the resource you are asking for.' }
schemas:
ShortenRequest:
required:
- url
properties:
slug:
type: string
url:
type: string
example: { url: 'https://some-obscure-url.com/' }
ShortenResponse:
properties:
shortenedUrl:
type: string
slug:
type: string
example:
{
'shortenedUrl': 'https://shorten.msroed.io/v1/foo-bar',
'slug': 'foo-bar',
}