-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenapi.yaml
318 lines (311 loc) · 11.6 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
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
openapi: 3.1.0
info:
title: Europeana Media Proxy
summary: thing
description: |
Micro-service for proxying Europeana `edm:isShownBy` and `edm:hasView` web
resources from providers' websites.
license:
name: EUPL-1.2
url: https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
contact:
url: https://github.com/europeana/media-proxy.js
version: 0.2.6
externalDocs:
description: Git repository README
url: https://github.com/europeana/media-proxy.js#readme
tags:
- name: media
description: Media proxying
- name: general
components:
parameters:
datasetId:
name: datasetId
in: path
description: Dataset ID of item
required: true
schema:
type: integer
examples:
oorlogsvlijt-example:
summary: '"Oorlogsvlijt in Harderwijk." item dataset ID'
value: 2020601
maalaus-example:
summary: '"maalaus" item (In Copyright) dataset ID'
value: 2021009
disposition:
name: disposition
in: query
description: "Content disposition: either attachment (default) or inline"
schema:
type: string
legacyRecordApiUrl:
name: api_url
in: query
description: |
Europeana Record API URL for web resource resolution & validation
(from legacy media proxy URLs)
schema:
type: string
legacyView:
name: view
in: query
description: Web resource URL to proxy (from legacy media proxy URLs)
schema:
type: string
localId:
name: localId
in: path
description: Local ID of item
required: true
schema:
type: string
examples:
oorlogsvlijt-example:
summary: '"Oorlogsvlijt in Harderwijk." item local ID'
value: https___1914_1918_europeana_eu_contributions_14524
maalaus-example:
summary: '"maalaus" item (In Copyright) local ID'
value: _0CD7C92E0A18088F22111B9C00BD5EF1
recordApiUrl:
name: recordApiUrl
in: query
description: |
Europeana Record API URL for web resource resolution & validation. If
it does not end with /record, that will be appended.
schema:
type: string
webResourceHash:
name: webResourceHash
in: path
description: MD5 hash of web resource URL
required: true
schema:
type: string
examples:
oorlogsvlijt-example:
summary: '"Oorlogsvlijt in Harderwijk." item web resource hash'
value: 304028f2553becc2bb0e4c0164439ec8
maalaus-example:
summary: '"maalaus" item (In Copyright) web resource hash'
value: 8634fa12ac4d030a2a45b55b78ee5582
responses:
400BadRequest:
description: |
Proxying aborted, due to requested Record API being unsupported
content:
"*/*":
schema:
type: string
example: Forbidden
paths:
/:
get:
tags:
- general
summary: Root
description: |
Returns "OK". May be used as a health check by monitoring systems.
operationId: getRootHealthCheck
responses:
"200":
description: OK if app is healthy
content:
"*/*":
schema:
type: string
example: OK
"/media/{datasetId}/{localId}":
parameters:
- $ref: "#/components/parameters/datasetId"
- $ref: "#/components/parameters/localId"
- $ref: "#/components/parameters/recordApiUrl"
- $ref: "#/components/parameters/disposition"
get:
tags:
- media
summary: Redirect to proxy media for edm:isShownBy
description: >
1. If a Record API URL has been specified in `recordApiUrl`, checks if
it is supported as a data source, and if not, responds with status
code 400. (If none specified, uses the default data source.)
1. Looks in our database for a Europeana item identified by the path
parameters `/{datasetId}/{localId}`. If no such item is found, responds
with status code 404.
1. Looks for a web resource associated with the item in its
`edm:isShownBy`property. If no such web resource is found, responds
with status code 404.
1. Responds with status code 302 to redirect to the endpoint for proxying
the media, by appending the MD5 hash of the web resource, i.e.
`/media/{datasetId}/{localId}/{webResourceHash}`. Any parameters in the
URL query will be preserved.
operationId: getRedirectEdmIsShownBy
responses:
"302":
description: Redirect
headers:
location:
description: Europeana media proxy URL including MD5 hash of edm:isShownBy
schema:
type: string
example: /media/2020601/https___1914_1918_europeana_eu_contributions_14524/304028f2553becc2bb0e4c0164439ec8
content:
"*/*":
schema:
type: string
example: Found. Redirecting to
/media/2020601/https___1914_1918_europeana_eu_contributions_14524/304028f2553becc2bb0e4c0164439ec8
"400":
$ref: "#/components/responses/400BadRequest"
"404":
description: Item not found, or has no edm:isShownBy
content:
"*/*":
schema:
type: string
example: Not Found
"/media/{datasetId}/{localId}/{webResourceHash}":
parameters:
- $ref: "#/components/parameters/datasetId"
- $ref: "#/components/parameters/localId"
- $ref: "#/components/parameters/webResourceHash"
- $ref: "#/components/parameters/recordApiUrl"
- $ref: "#/components/parameters/disposition"
- $ref: "#/components/headers/acceptAllHeader"
get:
tags:
- media
summary: Proxy media for specific web resource
description: >
1. If a Record API URL has been specified in `recordApiUrl`, checks if
it is supported as a data source, and if not, responds with status
code 400. (If none specified, uses the default data source.)
1. Looks in our database for a Europeana item identified by the path
parameters `/{datasetId}/{localId}`. If no such item is found, responds
with status code 404.
1. Looks for a web resource associated with the item in either its
`edm:isShownBy` or `edm:hasView` properties, whose URL when MD5-hashed
matches the path parameter `{webResourceHash}`. If no such web resource
is found, responds with status code 404.
1. Removes all but the following headers from the request before forwarding
it to the provider's site:
* `accept-encoding`
* `accept-language`
* `accept`
* `if-match`
* `if-modified-since`
* `range`
* `referer`
* `user-agent`
1. Starts proxying the web resource from the provider's site to the client.
1. If the web resource is detected to be an HTML document, stops proxying
and respond with status code 302 to redirect the client to the web page.
1. If the web resource is any other media type, preserve only these upstream
response headers, and remove the rest:
* `accept-ranges`
* `cache-control`
* `content-encoding`
* `content-length`
* `content-range`
* `content-type`
* `etag`
* `last-modified`
* `link`
1. If the upstream `content-type` header was omitted, default it to
"application/octet-stream".
1. Set the filename for the download (in the `content-disposition`
response header) based on the format `Europeana.eu-{datasetId}-{localId}-{webResourceHash}.{extension}`.
`{extension}` will be determined based on the `content-type` header
or default to "bin" if unable to.
1. Sets a custom response header `x-europeana-web-resource` containing
the upstream URL of the proxied media.
1. Respond with 200 status code.
operationId: getProxyWebResource
responses:
"200":
description: Media found and will be proxied
headers:
content-disposition:
description: >
Filename uses the format
Europeana.eu-{datasetId}-{localId}-{webResourceHash}.{extension}
schema:
type: string
example: attachment;
filename="Europeana.eu-2020601-https___1914_1918_europeana_eu_contributions_14524-304028f2553becc2bb0e4c0164439ec8.jpeg"
x-europeana-web-resource:
description: URL of proxied web resource
schema:
type: string
example: https://europeana1914-1918.s3.amazonaws.com/attachments/152075/14524.152075.original.jpg
content:
"*/*":
schema:
type: string
format: binary
"302":
description: Redirect to provider's site if requested media is HTML
headers:
location:
description: Redirect URL for HTML resource
schema:
type: string
example: https://www.example.org/
content:
"*/*":
schema:
type: string
example: Found. Redirecting to
/media/2020601/https___1914_1918_europeana_eu_contributions_14524/304028f2553becc2bb0e4c0164439ec8
"400":
$ref: "#/components/responses/400BadRequest"
"404":
description: Item not found, or has no such web resource
content:
"*/*":
schema:
type: string
example: Not Found
"/{datasetId}/{localId}":
parameters:
- $ref: "#/components/parameters/datasetId"
- $ref: "#/components/parameters/localId"
- $ref: "#/components/parameters/legacyRecordApiUrl"
- $ref: "#/components/parameters/legacyView"
- $ref: "#/components/parameters/disposition"
get:
tags:
- legacy
summary: Redirect legacy media proxy URLs to current equivalents
description: >
Legacy media proxy URLs are of the format
`/{datasetId}/{localId}?view={webResourceUrl}&apiUrl={recordApiUrl}`.
1. The URL in `webResourceUrl` will be hashed to get `webResourceHash`
1. The Record API URL in `apiUrl` will be moved to `recordApiUrl`
1. Any other URL query parameters will be preserved
1. The request will then be `301` redirected, e.g. to
`/media/{datasetId}/{localId}/{webResourceHash}?recordApiUrl={recordApiUrl}`
responses:
"301":
description: Redirect
headers:
location:
description: Europeana media proxy URL /media prefix, and optionally MD5 hash of
web resource
schema:
type: string
example: /media/2020601/https___1914_1918_europeana_eu_contributions_14524
content:
"*/*":
schema:
type: string
example: Found. Redirecting to
/media/2020601/https___1914_1918_europeana_eu_contributions_14524
servers:
- url: https://proxy.europeana.eu
description: Production server
- url: https://media-proxy-js.test.eanadev.org
description: Test server
- url: http://localhost:3000
description: Local development server