Repository navigation
Expand file tree
/
Copy pathopenapi.yaml
More file actions
393 lines (393 loc) · 18.2 KB
/
Copy pathopenapi.yaml
File metadata and controls
393 lines (393 loc) · 18.2 KB
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
openapi: 3.1.0
info:
title: OfflineShelf API
version: 0.1.0
description: >
Build Wikipedia reading lists. Every unsafe request (POST, PUT, PATCH, DELETE) needs the
session cookie and the token from GET /auth/csrf in the X-CSRF-Token header. Errors use
RFC 9457 problem details.
license:
name: MIT
identifier: MIT
servers:
- url: /api/v1
paths:
/health:
get:
operationId: health
responses:
'200': { description: All dependencies up, content: { application/json: { schema: { $ref: '#/components/schemas/Health' } } } }
'503': { description: A dependency is down, content: { application/json: { schema: { $ref: '#/components/schemas/Health' } } } }
/auth/csrf:
get:
operationId: getCsrf
responses:
'200': { description: Token for this session, content: { application/json: { schema: { $ref: '#/components/schemas/CsrfToken' } } } }
/auth/register:
post:
operationId: register
requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/Credentials' } } } }
responses:
'201': { description: Account created and signed in, content: { application/json: { schema: { $ref: '#/components/schemas/AuthResult' } } } }
'409': { $ref: '#/components/responses/Problem' }
'422': { $ref: '#/components/responses/Problem' }
'429': { $ref: '#/components/responses/Problem' }
/auth/login:
post:
operationId: login
requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/Credentials' } } } }
responses:
'200': { description: Signed in, content: { application/json: { schema: { $ref: '#/components/schemas/AuthResult' } } } }
'401': { $ref: '#/components/responses/Problem' }
'429': { $ref: '#/components/responses/Problem' }
/auth/logout:
post:
operationId: logout
responses:
'200': { description: Signed out; a fresh token for the new session, content: { application/json: { schema: { $ref: '#/components/schemas/CsrfOnly' } } } }
/auth/logout-everywhere:
post:
operationId: logoutEverywhere
responses:
'200': { description: Every session of this account ended, content: { application/json: { schema: { $ref: '#/components/schemas/CsrfOnly' } } } }
'401': { $ref: '#/components/responses/Problem' }
/auth/me:
get:
operationId: me
responses:
'200': { description: The signed-in user, content: { application/json: { schema: { type: object, required: [user], properties: { user: { $ref: '#/components/schemas/User' } } } } } }
'401': { $ref: '#/components/responses/Problem' }
/lists:
get:
operationId: listLists
parameters:
- { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 100, default: 20 } }
- { name: cursor, in: query, schema: { type: integer } }
responses:
'200': { description: Newest first, content: { application/json: { schema: { $ref: '#/components/schemas/ListPage' } } } }
'401': { $ref: '#/components/responses/Problem' }
post:
operationId: createList
requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/ListCreate' } } } }
responses:
'201': { description: Created, content: { application/json: { schema: { $ref: '#/components/schemas/ShelfList' } } } }
'401': { $ref: '#/components/responses/Problem' }
'422': { $ref: '#/components/responses/Problem' }
/lists/{listId}:
parameters:
- { name: listId, in: path, required: true, schema: { type: integer } }
get:
operationId: getList
responses:
'200': { description: The list, content: { application/json: { schema: { $ref: '#/components/schemas/ShelfList' } } } }
'404': { $ref: '#/components/responses/Problem' }
delete:
operationId: deleteList
responses:
'204': { description: Deleted }
'404': { $ref: '#/components/responses/Problem' }
'409': { $ref: '#/components/responses/Problem' }
/lists/{listId}/build:
parameters:
- { name: listId, in: path, required: true, schema: { type: integer } }
post:
operationId: buildList
description: Queues a build. The new version starts as queued; poll it until ready or failed.
responses:
'202': { description: Build queued, content: { application/json: { schema: { $ref: '#/components/schemas/ListVersion' } } } }
'404': { $ref: '#/components/responses/Problem' }
'409': { $ref: '#/components/responses/Problem' }
'429': { $ref: '#/components/responses/Problem' }
/lists/{listId}/versions:
parameters:
- { name: listId, in: path, required: true, schema: { type: integer } }
get:
operationId: listVersions
parameters:
- { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 100, default: 20 } }
- { name: cursor, in: query, schema: { type: integer } }
responses:
'200': { description: Newest first, content: { application/json: { schema: { $ref: '#/components/schemas/VersionPage' } } } }
'404': { $ref: '#/components/responses/Problem' }
/lists/{listId}/versions/{versionId}:
parameters:
- { name: listId, in: path, required: true, schema: { type: integer } }
- { name: versionId, in: path, required: true, schema: { type: integer } }
get:
operationId: getVersion
responses:
'200': { description: The version, content: { application/json: { schema: { $ref: '#/components/schemas/ListVersion' } } } }
'404': { $ref: '#/components/responses/Problem' }
/lists/{listId}/versions/{versionId}/articles:
parameters:
- { name: listId, in: path, required: true, schema: { type: integer } }
- { name: versionId, in: path, required: true, schema: { type: integer } }
get:
operationId: listArticles
parameters:
- { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 1000, default: 100 } }
- { name: cursor, in: query, schema: { type: integer } }
responses:
'200': { description: In insertion order, content: { application/json: { schema: { $ref: '#/components/schemas/ArticlePage' } } } }
'404': { $ref: '#/components/responses/Problem' }
/lists/{listId}/versions/{versionId}/changes:
parameters:
- { name: listId, in: path, required: true, schema: { type: integer } }
- { name: versionId, in: path, required: true, schema: { type: integer } }
get:
operationId: listChanges
description: Articles added since the previous ready version, or removed from it, by page ID.
parameters:
- { name: kind, in: query, schema: { type: string, enum: [added, removed], default: added } }
- { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 1000, default: 100 } }
- { name: cursor, in: query, schema: { type: integer } }
responses:
'200': { description: Changed articles, content: { application/json: { schema: { $ref: '#/components/schemas/ArticlePage' } } } }
'404': { $ref: '#/components/responses/Problem' }
'422': { $ref: '#/components/responses/Problem' }
/lists/{listId}/versions/{versionId}/export.tsv:
parameters:
- { name: listId, in: path, required: true, schema: { type: integer } }
- { name: versionId, in: path, required: true, schema: { type: integer } }
get:
operationId: exportTsv
description: >-
Streams the articles of a ready version as tab-separated values with the columns
title, page_id and revision_id. Lines starting with "#" before the column header carry
the source wiki, build time and CC BY-SA 4.0 attribution.
responses:
'200': { description: TSV file, content: { text/tab-separated-values: { schema: { type: string } } } }
'404': { $ref: '#/components/responses/Problem' }
'409': { $ref: '#/components/responses/Problem' }
/lists/{listId}/versions/{versionId}/exports:
parameters:
- { name: listId, in: path, required: true, schema: { type: integer } }
- { name: versionId, in: path, required: true, schema: { type: integer } }
get:
operationId: listExports
responses:
'200': { description: The ten most recent exports, newest first, content: { application/json: { schema: { $ref: '#/components/schemas/ExportList' } } } }
'404': { $ref: '#/components/responses/Problem' }
post:
operationId: createExport
description: >-
Queues an export of a ready version: one Parsoid HTML page per article with links between
exported articles rewritten, an index and an attribution page, as a zip (html) or a ZIM
file for Kiwix (zim). If an
export of this version is already queued, running or ready, that one is returned.
Bundles expire after 7 days.
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/ExportCreate' } } }
responses:
'202': { description: Queued (or the existing export), content: { application/json: { schema: { $ref: '#/components/schemas/Export' } } } }
'404': { $ref: '#/components/responses/Problem' }
'409': { $ref: '#/components/responses/Problem' }
'422': { $ref: '#/components/responses/Problem' }
/lists/{listId}/exports/{exportId}/download:
parameters:
- { name: listId, in: path, required: true, schema: { type: integer } }
- { name: exportId, in: path, required: true, schema: { type: integer } }
get:
operationId: downloadExport
responses:
'200': { description: The zip or ZIM file, content: { application/zip: { schema: { type: string, format: binary } }, application/x-zim: { schema: { type: string, format: binary } } } }
'404': { $ref: '#/components/responses/Problem' }
'410': { $ref: '#/components/responses/Problem' }
components:
responses:
Problem:
description: Error
content: { application/problem+json: { schema: { $ref: '#/components/schemas/Problem' } } }
schemas:
Health:
type: object
required: [status, checks]
properties:
status: { type: string, enum: [ok, degraded] }
checks: { type: object, additionalProperties: { type: string, enum: [ok, down] } }
CsrfToken:
type: object
required: [token]
properties: { token: { type: string } }
CsrfOnly:
type: object
required: [csrf]
properties: { csrf: { type: string } }
Credentials:
type: object
additionalProperties: false
required: [email, password]
properties:
email: { type: string, format: email, maxLength: 254 }
password: { type: string, minLength: 12, maxLength: 256 }
User:
type: object
required: [id, email]
properties: { id: { type: integer }, email: { type: string } }
AuthResult:
type: object
required: [user, csrf]
properties: { user: { $ref: '#/components/schemas/User' }, csrf: { type: string } }
BuilderKind: { type: string, enum: [category, wikidata, pasted, pageviews, combination] }
Schedule: { type: string, enum: [none, monthly] }
VersionStatus: { type: string, enum: [queued, building, ready, failed] }
CategoryParams:
type: object
additionalProperties: false
required: [kind, category]
properties:
kind: { const: category }
category: { type: string, minLength: 1, maxLength: 255 }
depth: { type: integer, minimum: 0, maximum: 5, default: 0 }
WikidataParams:
type: object
additionalProperties: false
required: [kind, sparql]
properties:
kind: { const: wikidata }
sparql: { type: string, minLength: 1, maxLength: 10000 }
PastedParams:
type: object
additionalProperties: false
required: [kind, titles]
properties:
kind: { const: pasted }
titles: { type: array, minItems: 1, maxItems: 20000, items: { type: string, minLength: 1, maxLength: 255 } }
PageviewsParams:
type: object
additionalProperties: false
required: [kind, year, month, limit]
properties:
kind: { const: pageviews }
year: { type: integer, minimum: 2016 }
month: { type: integer, minimum: 1, maximum: 12 }
limit: { type: integer, minimum: 1, maximum: 1000 }
CombinationParams:
type: object
additionalProperties: false
description: >-
Union, intersection or difference (the first list minus the others) of the latest ready
versions of 2 to 10 of your lists on the same wiki. Rebuilds when a source list gets a
new version.
required: [kind, operation, sources]
properties:
kind: { const: combination }
operation: { type: string, enum: [union, intersection, difference] }
sources: { type: array, items: { type: integer }, minItems: 2, maxItems: 10, uniqueItems: true }
ListCreate:
type: object
additionalProperties: false
required: [name, wiki, params]
properties:
name: { type: string, minLength: 1, maxLength: 120 }
wiki: { type: string, maxLength: 64, examples: [en.wikipedia.org] }
params:
oneOf:
- $ref: '#/components/schemas/CategoryParams'
- $ref: '#/components/schemas/WikidataParams'
- $ref: '#/components/schemas/PastedParams'
- $ref: '#/components/schemas/PageviewsParams'
- $ref: '#/components/schemas/CombinationParams'
discriminator:
propertyName: kind
mapping:
category: '#/components/schemas/CategoryParams'
wikidata: '#/components/schemas/WikidataParams'
pasted: '#/components/schemas/PastedParams'
pageviews: '#/components/schemas/PageviewsParams'
combination: '#/components/schemas/CombinationParams'
schedule: { $ref: '#/components/schemas/Schedule' }
ShelfList:
type: object
required: [id, name, wiki, builder, params, schedule, created_at, latest_status]
properties:
id: { type: integer }
name: { type: string }
wiki: { type: string }
builder: { $ref: '#/components/schemas/BuilderKind' }
params: { type: object, additionalProperties: true }
schedule: { $ref: '#/components/schemas/Schedule' }
created_at: { type: string, format: date-time }
latest_status: { oneOf: [{ $ref: '#/components/schemas/VersionStatus' }, { type: 'null' }] }
ListPage:
type: object
required: [items, next_cursor]
properties:
items: { type: array, items: { $ref: '#/components/schemas/ShelfList' } }
next_cursor: { oneOf: [{ type: integer }, { type: 'null' }] }
ListVersion:
type: object
required: [id, status, started_at, finished_at, article_count, error, report, previous_version_id, added_count, removed_count]
properties:
id: { type: integer }
status: { $ref: '#/components/schemas/VersionStatus' }
started_at: { oneOf: [{ type: string, format: date-time }, { type: 'null' }] }
finished_at: { oneOf: [{ type: string, format: date-time }, { type: 'null' }] }
article_count: { type: integer }
error: { oneOf: [{ type: string }, { type: 'null' }] }
report: { oneOf: [{ type: object, additionalProperties: true }, { type: 'null' }] }
previous_version_id: { oneOf: [{ type: integer }, { type: 'null' }], description: The ready version this one was compared with }
added_count: { oneOf: [{ type: integer }, { type: 'null' }], description: Articles not in the previous ready version }
removed_count: { oneOf: [{ type: integer }, { type: 'null' }], description: Articles of the previous ready version that are gone }
VersionPage:
type: object
required: [items, next_cursor]
properties:
items: { type: array, items: { $ref: '#/components/schemas/ListVersion' } }
next_cursor: { oneOf: [{ type: integer }, { type: 'null' }] }
ExportCreate:
type: object
additionalProperties: false
properties:
format: { type: string, enum: [html, zim], default: html, description: 'html: a zip of offline pages; zim: one ZIM file for the Kiwix apps' }
Export:
type: object
required: [id, version_id, format, status, progress, total, size_bytes, missing, error, created_at, finished_at, expires_at]
properties:
id: { type: integer }
version_id: { type: integer }
format: { type: string }
status: { type: string, enum: [queued, building, ready, failed] }
progress: { type: integer, description: Articles fetched so far }
total: { type: integer, description: Articles in the version }
size_bytes: { type: [integer, 'null'] }
missing: { type: [array, 'null'], items: { type: string }, description: Titles whose pages no longer exist }
error: { type: [string, 'null'] }
created_at: { type: string, format: date-time }
finished_at: { type: [string, 'null'], format: date-time }
expires_at: { type: [string, 'null'], format: date-time }
ExportList:
type: object
required: [items]
properties:
items: { type: array, items: { $ref: '#/components/schemas/Export' } }
Article:
type: object
required: [page_id, title, revision_id]
properties:
page_id: { type: integer }
title: { type: string }
revision_id: { oneOf: [{ type: integer }, { type: 'null' }] }
ArticlePage:
type: object
required: [items, next_cursor]
properties:
items: { type: array, items: { $ref: '#/components/schemas/Article' } }
next_cursor: { oneOf: [{ type: integer }, { type: 'null' }] }
Problem:
type: object
required: [type, title, status]
properties:
type: { type: string }
title: { type: string }
status: { type: integer }
detail: { type: string }
errors:
type: array
items:
type: object
properties:
loc: { type: array, items: { oneOf: [{ type: string }, { type: integer }] } }
msg: { type: string }
type: { type: string }