-
Notifications
You must be signed in to change notification settings - Fork 0
/
openapi.yaml
287 lines (281 loc) Β· 7.63 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
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
openapi: 3.0.0
info:
title: Analytics
description: A simple analytics API.
version: 0.0.0
servers:
- url: https://e1-analytics.herokuapp.com/1.0
- url: http://localhost:3000/1.0
tags:
- name: Events
description: Events are the individual data points collected by the API. These events are stored in collections.
- name: Projects
description: Projects
components:
securitySchemes:
RootKey:
type: apiKey
in: header
name: X-Root-Key
description: The instance root key is used for managing projects.
WriteKeyHeader:
type: apiKey
in: header
name: Authorization
WriteKeyQuery:
type: apiKey
in: query
name: api_key
schemas:
CreateProjectScema:
type: object
required:
- name
properties:
name:
type: string
description: Specifies the name of the project
example: 'Test Project'
ProjectScema:
type: object
required:
- name
properties:
_id:
type: string
example: 5e19426836270c1b1e7b03f2
name:
type: string
description: Specifies the name of the project
example: 'Test Project'
masterKey:
type: string
example: <MASTER_API_KEY>
readKey:
type: string
example: <READ_API_KEY>
writeKey:
type: string
example: <WRITE_API_KEY>
createdAt:
type: string
example: '2020-01-11T13:38:05.006Z'
updatedAt:
type: string
example: '2020-01-11T21:18:56.035Z'
responses:
BadRequestError:
description: Missing or invalid parameters. Error messages will often contain more information to help you figure out whatβs wrong.
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: 'Failed to parse data.'
error_code:
type: string
default: BadRequestError
UnauthorizedError:
description: API key is missing or invalid
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: 'The API Key is invalid.'
error_code:
type: string
default: UnauthorizedError
NotFoundError:
description: The requested resource was not found.
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: 'Resource not found.'
error_code:
type: string
default: NotFoundError
EventCreated:
description: Event created successfully
content:
application/json:
schema:
type: object
properties:
created:
type: boolean
default: true
Project:
description: A project object
content:
application/json:
schema:
$ref: '#/components/schemas/ProjectScema'
Projects:
description: A project object
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ProjectScema'
parameters:
ProjectIdParam:
in: path
name: projectId
schema:
type: string
example: 5e19426836270c1b1e7b03f2
required: true
description: ID of the project.
CollectionNameParam:
in: path
name: collectionName
schema:
type: string
example: your_event
required: true
description: Name of the event collection to record the event in.
paths:
/projects/{projectId}/events/{collectionName}:
post:
summary: Record a single event
security:
- WriteKeyHeader: []
- WriteKeyQuery: []
tags:
- Events
parameters:
- $ref: '#/components/parameters/ProjectIdParam'
- $ref: '#/components/parameters/CollectionNameParam'
responses:
'201':
$ref: '#/components/responses/EventCreated'
'400':
$ref: '#/components/responses/BadRequestError'
'401':
$ref: '#/components/responses/UnauthorizedError'
'404':
$ref: '#/components/responses/NotFoundError'
requestBody:
description: Key value object of the event body
required: false
content:
application/json:
schema:
type: object
default: {}
example: { key: 'value' }
get:
summary: Record a single event
security:
- WriteKeyHeader: []
- WriteKeyQuery: []
tags:
- Events
parameters:
- $ref: '#/components/parameters/ProjectIdParam'
- $ref: '#/components/parameters/CollectionNameParam'
- in: query
name: data
schema:
type: string
description: URL-encoded AND base-64 encoded event body
- in: query
name: redirect
schema:
type: string
description: A URL to redirect the request toward after the event is recorded.
responses:
'201':
$ref: '#/components/responses/EventCreated'
'400':
$ref: '#/components/responses/BadRequestError'
'401':
$ref: '#/components/responses/UnauthorizedError'
'404':
$ref: '#/components/responses/NotFoundError'
/projects:
get:
summary: Get projects
security:
- RootKey: []
tags:
- Projects
responses:
'200':
$ref: '#/components/responses/Projects'
'401':
$ref: '#/components/responses/UnauthorizedError'
post:
summary: Create project
security:
- RootKey: []
tags:
- Projects
requestBody:
description: New project
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateProjectScema'
responses:
'200':
$ref: '#/components/responses/Project'
'400':
$ref: '#/components/responses/BadRequestError'
'401':
$ref: '#/components/responses/UnauthorizedError'
'404':
$ref: '#/components/responses/NotFoundError'
/projects/{projectId}:
get:
summary: Get project
security:
- RootKey: []
tags:
- Projects
parameters:
- $ref: '#/components/parameters/ProjectIdParam'
responses:
'200':
$ref: '#/components/responses/Project'
'400':
$ref: '#/components/responses/BadRequestError'
'401':
$ref: '#/components/responses/UnauthorizedError'
'404':
$ref: '#/components/responses/NotFoundError'
post:
summary: Update project
security:
- RootKey: []
tags:
- Projects
requestBody:
description: Updated project
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateProjectScema'
parameters:
- $ref: '#/components/parameters/ProjectIdParam'
responses:
'200':
$ref: '#/components/responses/Project'
'400':
$ref: '#/components/responses/BadRequestError'
'401':
$ref: '#/components/responses/UnauthorizedError'
'404':
$ref: '#/components/responses/NotFoundError'