-
Notifications
You must be signed in to change notification settings - Fork 80
/
pdf.yaml
83 lines (82 loc) · 3.02 KB
/
pdf.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
openapi: 3.0.1
info:
version: 1.0.0-beta
title: MediaWiki PDF API
description: Page PDF Render API
termsOfService: https://github.com/wikimedia/restbase#restbase
contact:
name: Services
email: services@lists.wikimedia.org
url: https://www.mediawiki.org/wiki/Services
license:
name: Apache licence, v2
url: https://www.apache.org/licenses/LICENSE-2.0
paths:
/pdf/{title}:
x-route-filters:
- path: ./lib/access_check_filter.js
options:
redirect_cache_control: '{{options.cache_control}}'
get:
tags:
- Page content
summary: Get a page as PDF
description: |
Renders the page content as PDF.
Stability: [experimental](https://www.mediawiki.org/wiki/API_versioning#Experimental)
parameters:
- name: title
in: path
description: 'Page title. Use underscores instead of spaces. Example: `Main_Page`.'
required: true
schema:
type: string
responses:
200:
description: The PDF render of an article
headers:
ETag:
description: |
Syntax: "{revision}/{tid}". Example: "701384379/154d7bca-c264-11e5-8c2f-1b51b33b59fc"
schema:
type: string
content:
application/pdf:
schema:
type: string
404:
description: Unknown page title
content:
application/problem+json:
schema:
$ref: '#/components/schemas/problem'
default:
description: Error
content:
application/problem+json:
schema:
$ref: '#/components/schemas/problem'
x-request-handler:
- get_latest_revision:
request:
method: get
uri: /{domain}/sys/page_revisions/page/{title}
- get_pdf_from_backend:
request:
method: get
# Hard-coded output options will be replaced later by extending
# the RESTBase endpoint with additional paramters. Defaults
# will be A4 and desktop if no parameters are provided.
uri: '{{options.uri}}/{{domain}}/v1/pdf/{title}/a4/desktop'
return:
status: 200
headers:
# Firefox supports filename*= syntax while Chrome respect
# filename=. Safari is stupid and understands neither.
content-disposition: 'attachment; {{filenameParameters(request.params.title)}}'
content-type: '{{get_pdf_from_backend.headers.content-type}}'
content-length: '{{get_pdf_from_backend.headers.content-length}}'
cache-control: '{{default(options.cache_control, "s-maxage=600, max-age=600")}}'
etag: '{{get_latest_revision.headers.etag}}'
body: '{{get_pdf_from_backend.body}}'
x-monitor: false # PDF generation is expensive and it's not stored, so don't run checker script