-
Notifications
You must be signed in to change notification settings - Fork 0
/
swagger.yml
124 lines (122 loc) · 3.7 KB
/
swagger.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
swagger: "2.0"
info:
title: "Urlshortener"
version: "0.0.1"
basePath: "/v1"
paths:
/shrink:
post:
summary: "Сократить ссылку"
parameters:
- in: body
name: body
required: true
schema:
$ref: "#/definitions/SourceLink"
responses:
200:
description: "Успешная операция"
schema:
type: object
allOf:
- { $ref: '#/definitions/ApiResult' }
- { properties: { data: {type: object, $ref: "#/definitions/ProcessedLink"}, success: {type: boolean, example: true } } }
400:
description: "Ошибка валидации параметров"
schema:
type: object
allOf:
- { $ref: '#/definitions/ApiResult' }
- { properties: { success: {type: boolean, example: false } } }
500:
description: "Внутренняя ошибка"
schema:
type: object
allOf:
- { $ref: '#/definitions/ApiResult' }
- { properties: { success: {type: boolean, example: false } } }
/{shortCode}:
get:
summary: "Represents a short URL. Tracks the visit and redirects tio 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:
type: object
allOf:
- { $ref: '#/definitions/ApiResult' }
- { properties: { data: {type: object, $ref: "#/definitions/RedirectUrl"}, success: {type: boolean, example: true } } }
404:
description: "Ссылка не найдена"
schema:
type: object
allOf:
- { $ref: '#/definitions/ApiResult' }
- { properties: { success: {type: boolean, example: false } } }
500:
description: "Внутренняя ошибка"
schema:
type: object
allOf:
- { $ref: '#/definitions/ApiResult' }
- { properties: { success: {type: boolean, example: false } } }
definitions:
ApiResult:
description: "Стандартизированный ответ API"
properties:
data:
description: "Данные"
type: object
meta:
description: "Разная опциональная дополнительная информация"
type: object
errors:
description: "Список ошибок"
type: object
success:
description: "Результат выполнения запроса (true - нет ошибки, false - ошибка)"
type: boolean
example: true
type: object
SourceLink:
type: object
description: "Исходная длинная ссылка"
required:
- long_url
properties:
long_url:
type: string
format: url
ProcessedLink:
type: object
description: "Сокращённая ссылка"
properties:
id:
type: string
long_url:
type: string
format: url
short_url:
type: string
format: url
RedirectUrl:
type: object
description: "URL для редиректа"
properties:
long_url:
type: string
format: url