-
Notifications
You must be signed in to change notification settings - Fork 5
/
swagger.yaml
301 lines (298 loc) · 7.76 KB
/
swagger.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
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
swagger: "2.0"
info:
title: Go Auth service
description: HTTP API for authentication and authorization.
version: "1.0.0"
consumes:
- "application/json"
produces:
- "application/json"
paths:
/users:
post:
summary: Registers user account
description: |
Registers new user account given email and password. New account will
be uniquely identified by its email address.
tags:
- users
parameters:
- name: user
description: JSON-formatted document describing the new user.
in: body
schema:
$ref: "#/definitions/User"
required: true
responses:
201:
description: Registered new user.
400:
description: Failed due to malformed JSON.
409:
description: Failed due to using an existing email address.
500:
$ref: "#/responses/ServiceError"
get:
summary: Retrieves user accounts
description: |
Retrieves a list of user accounts. Due to performance concerns, data
is retrieved in subsets. The API clients must ensure that the entire
dataset is consumed either by making subsequent requests, or by
increasing the subset size of the initial request.
tags:
- channels
parameters:
- $ref: "#/parameters/Authorization"
- $ref: "#/parameters/Size"
- $ref: "#/parameters/Offset"
responses:
200:
description: Data retrieved.
headers:
X-Count:
type: integer
description: |
Total number of managed channels. This value can be used to
implement the paging strategy on API clients.
schema:
$ref: "#/definitions/UserList"
400:
description: Failed due to malformed query parameters.
403:
description: Missing or invalid access token provided.
500:
$ref: "#/responses/ServiceError"
/users/{id}:
get:
summary: Retrieves user info
tags:
- channels
parameters:
- $ref: "#/parameters/Authorization"
- $ref: "#/parameters/Id"
responses:
200:
description: Data retrieved.
schema:
$ref: "#/definitions/UserRes"
403:
description: Missing or invalid access token provided.
404:
description: Channel does not exist.
500:
$ref: "#/responses/ServiceError"
put:
summary: Updates user info
description: |
Update is performed by replacing the current resource data with values
provided in a request payload. Resource's unique identifier will not be
affected.
tags:
- channels
parameters:
- $ref: "#/parameters/Authorization"
- $ref: "#/parameters/Id"
- name: channel
description: JSON-formatted document describing the updated channel.
in: body
schema:
$ref: "#/definitions/UserReq"
required: true
responses:
200:
description: User updated.
400:
description: Failed due to malformed JSON.
403:
description: Missing or invalid access token provided.
404:
description: User does not exist.
500:
$ref: "#/responses/ServiceError"
delete:
summary: Removes a user account
description: |
Removes user account. The service will ensure that the subscribed apps and
devices are unsubscribed from the removed channel.
tags:
- channels
parameters:
- $ref: "#/parameters/Authorization"
- $ref: "#/parameters/Id"
responses:
204:
description: User removed.
403:
description: Missing or invalid access token provided.
500:
$ref: "#/responses/ServiceError"
/login:
post:
summary: User authentication
description: |
Generates an access token when provided with proper credentials.
tags:
- users
parameters:
- name: credentials
description: JSON-formatted document containing user credentials.
in: body
schema:
$ref: "#/definitions/User"
required: true
responses:
201:
description: User authenticated.
schema:
$ref: "#/definitions/Token"
400:
description: |
Failed due to malformed JSON or using an invalid credentials.
500:
$ref: "#/responses/ServiceError"
/auth:
get:
summary: Checks the token validity
description: |
If the request is made using valid token, an identifier bound
to that token will be returned.
tags:
- access control
parameters:
- $ref: "#/parameters/Authorization"
responses:
200:
description: ID retrieved
headers:
X-client-id:
type: string
description: ID of the entity bound to the provided access key.
403:
description: Missing or invalid access token provided.
parameters:
Authorization:
name: Authorization
description: User's access token.
in: header
type: string
required: true
Id:
name: id
description: Unique resource identifier.
in: path
type: string
format: uuid
required: true
Size:
name: size
description: Size of the subset to retrieve.
in: query
type: integer
default: 10
required: false
Offset:
name: offset
description: Number of items to skip during retrieval.
in: query
type: integer
default: 0
required: false
responses:
ServiceError:
description: Unexpected server-side error occured.
definitions:
UserList:
type: object
properties:
channels:
type: array
minItems: 0
uniqueItems: true
items:
$ref: "#/definitions/UserRes"
required:
- channels
UserRes:
type: object
properties:
id:
type: string
description: Unique user identifier generated by the service.
email:
type: string
description: Free-form channel name.
connected:
type: array
minItems: 0
uniqueItems: true
items:
type: string
required:
- id
- name
- connected
ChannelReq:
type: object
properties:
name:
type: string
description: Free-form channel name.
connected:
type: array
minItems: 0
uniqueItems: true
items:
type: string
ClientList:
type: object
properties:
clients:
type: array
minItems: 0
uniqueItems: true
items:
$ref: "#/definitions/ClientRes"
required:
- clients
User:
type: object
properties:
email:
type: string
format: email
example: "[email protected]"
description: User's email address will be used as its unique identifier
password:
type: string
format: password
description: Free-form account password used for acquiring auth token(s).
required:
- email
- password
UserReq:
type: object
properties:
type:
type: string
enum:
- app
- device
description: Type of the client.
name:
type: string
description: Free-form client name.
meta:
type: object
description: Client's meta-data.
additionalProperties:
type: string
required:
- type
Token:
type: object
properties:
token:
type: string
description: Generated access token.
required:
- token