-
Notifications
You must be signed in to change notification settings - Fork 7
/
openapi.yml
581 lines (575 loc) · 19.4 KB
/
openapi.yml
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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
# Swagger spec for Scholarsphere (see https://swagger.io/specification/)
openapi: "3.0.2"
info:
title: "ScholarSphere"
description: "API specification for ScholarSphere"
termsOfService: "https://scholarsphere.psu.edu/about"
contact:
name: "ScholarSphere Support"
email: "https://scholarsphere.psu.edu/help"
license:
name: "MIT"
url: "https://opensource.org/licenses/MIT"
version: "1.0"
servers:
- url: "https://scholarsphere.psu.edu/api/{version}"
description: "API endpoint"
variables:
version:
description: "Version of the API"
enum:
- v1
default: "v1"
# Listing of the basic model concepts used in the application (see https://swagger.io/specification/#tagObject)
tags:
- name: "Work"
description: "The primary unit of content in ScholarSphere"
- name: "WorkVersion"
description: "An instance of work, containing descriptive metadata and binary content"
- name: "Collection"
description: "A resource with descriptive metadata containing an ordered grouping of works"
- name: "Actor"
description: >-
An identifiable person who has a relationship to a work or collection. They are linked to resources in two ways:
1) a depositor, linked directly to the resource; or 2) a creator, linked to a resource via an authorship.
Any given actor will have zero to many authorships.
- name: "Authorship"
description: >-
A person who has authored a resource, either a collection or work. These are listed as "creators" in the
application. If the person is identifiable, either via a Penn State access id or an Orcid, they will have a
corresponding linked actor record. If they are not identifiable, there is no linked actor record.
# Paths Object, containing multiple Path Item Objects. Each path item will contain multiple Operation Objects.
# See:
# https://swagger.io/specification/#pathsObject
# https://swagger.io/specification/#pathItemObject
# https://swagger.io/specification/#operationObject
paths:
/ingest:
post:
summary: "Publishes a new work"
description: >-
Creates a new work with a single version, and if all the requirements are present, the version will be published
and publicly available.
security:
- APIKey: []
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ingest"
responses:
200:
description: "The work was successfully published"
201:
description: "The work was created, but not published"
default:
$ref: "#/components/responses/defaultPostError"
/collections:
post:
summary: "Creates a new collection"
/dois:
get:
summary: "List of all DOIs"
description: >-
Retrieve a dictionary of all DOIs known to Scholarsphere. The keys in
this dictionary will be the DOI, like `"doi:10.26207/002c-bb83"` and the
value will be an array of UUIDs of all resources that reference that DOI
security:
- APIKey: []
responses:
200:
description: A list of all DOIs
content:
application/json:
schema:
$ref: "#/components/schemas/doi_list"
/dois/{doi}:
get:
summary: "Search for a DOI"
description: >-
Retrieve a list of resources that mention the given DOI.
security:
- APIKey: []
parameters:
- name: doi
in: path
description: >-
A DOI name, including the slash ("/"). Just put the slash right in
the url, like `/dois/10.26207/002c-bb83`
required: true
schema:
type: "string"
example: "10.26207/002c-bb83"
responses:
200:
description: "The DOI was found in one or more resources"
content:
application/json:
schema:
$ref: "#/components/schemas/doi_response"
404:
description: "The DOI was not found in any of ScholarSphere's resources"
/files:
put:
summary: "Updates a file's metadata"
description: >-
The client can update a file's metadata, such as the results of a virus scan or other async process.
security:
- APIKey: []
requestBody:
description: "Posting updating information for a file after checking for viruses"
content:
application/json:
schema:
$ref: '#/components/schemas/fileMetadata'
examples:
novirus:
summary: "No virus was found in the file"
description: >-
Client posts a json object containing the results of the virus check and when it was performed.
value:
id: '1'
metadata:
virus:
status: 'false'
scanned_at: '2021-01-25'
yesvirus:
summary: "A virus was found in the file"
description: >-
Client posts a json object containing a positive virus check and when it was performed.
value:
id: '1'
metadata:
virus:
status: 'true'
scanned_at: '2021-01-25'
responses:
200:
description: >-
The file's metadata was successfully updated.
content:
application/json:
schema:
$ref: "#/components/schemas/successResponse"
examples:
summary: "The client is not authorized to perform the requested action"
value:
message: "File was successfully updated"
default:
$ref: "#/components/responses/defaultPostError"
/featured_resources:
post:
summary: "Adds a new featured resource to the home page"
security:
- APIKey: []
requestBody:
description: "Given an existing UUID for a resource, feature it on the homepage"
content:
application/json:
schema:
$ref: '#/components/schemas/featuredResource'
examples:
standard:
summary: "Makes this work a featured work on the homepage"
description: >-
Client posts a json object containing the uuid of the resource they want to have featured.
value:
uuid: 'a0fc525b-0d49-48e0-a385-f86bd13bce4d'
responses:
200:
description: >-
If the resources has been featured before, or is already featured, it will update with a new timestamp and
moved to the top of the list.
201:
description: >-
The resource has not been featured before, and a new entry is made in the list of featured resources, moving
this one to the top.
default:
$ref: "#/components/responses/defaultPostError"
/uploads:
post:
summary: "Requests a pre-signed URL to upload a file into ScholarSphere's S3 instance"
security:
- APIKey: []
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/uploads"
# Array of Schema Objects used to define the concepts/models (see https://swagger.io/specification/#schemaObject)
components:
schemas:
doi_list:
type: "object"
additionalProperties:
type: "array"
description: "a list of resource UUIDs"
items:
type: "string"
description: "a resource UUID"
example: "a0fc525b-0d49-48e0-a385-f86bd13bce4d"
example:
"doi:10.26207/002c-bb83":
- "a0fc525b-0d49-48e0-a385-f86bd13bce4d"
- "146a74e3-ae66-4802-b5f8-471bcac80d58"
"doi:10.18113/dmnf-6dzs":
- "87287b53-76be-424e-b202-bc6d521c841b"
doi_response:
type: "array"
items:
type: "object"
properties:
url:
type: "string"
format: "uri"
example: "/resources/a0fc525b-0d49-48e0-a385-f86bd13bce4d"
description: "path to a Scholarsphere resource"
uuid:
type: "object"
properties:
uuid:
type: "string"
example: "a0fc525b-0d49-48e0-a385-f86bd13bce4d"
id:
type: "object"
properties:
id:
type: "integer"
example: '1'
metadata:
type: "object"
required:
- "title"
- "work_type"
- "description"
- "published_date"
- "creators"
- "rights"
- "visibility"
properties:
title:
type: "string"
example: "Classifying Independent Hybridity"
work_type:
type: "string"
enum:
- article
- audio
- book
- collection
- conference_proceeding
- dataset
- image
- journal
- map_or_cartographic_material
- masters_culminating_experience
- other
- part_of_book
- poster
- presentation
- professional_doctoral_culminating_experience
- project
- report
- research_paper
- software_or_program_code
- video
example: "dataset"
description:
type: "string"
example: >-
Anaesthesiology anthropology chaology craniology ecology endocrinology epileptology gnomonics ichthyology
linguistics mammalogy mazology nasology nematology neurobiology palaeontology psychopathology pterylology
textology toponymics. Aerostatics anemology avionics diplomatology euthenics geochemistry historiography
historiology hydrology hydrometeorology hygiastics iatromathematics lexigraphy martyrology metallogeny
neonatology numismatics oikology patrology pestology photobiology psychobiology psychology sphagnology
stemmatology threpsology ufology vinology. Arctophily astrophysics carcinology dactylology electrology
genealogy horography hydrobiology immunopathology lexigraphy molinology nidology paidonosology
palaeopedology venereology.
published_date:
type: "string"
format: "date"
example: "2020-10-31"
description: >-
EDTF date formats are also supported. See https://www.loc.gov/standards/datetime/
publisher_statement:
type: "string"
example: >-
This is a pre-print from Joe Publisher, Inc. We are not responsible for anything.
description: >-
This is also referred to as a "set statement" and is often a required part for Open Access articles.
keyword:
type: "array"
items:
type: "string"
example: ["optics", "quantum physics", "fake paper names"]
subtitle:
type: "string"
example: "Quantum Optics and/in the Clan"
publisher:
type: "array"
items:
type: "string"
subject:
type: "array"
items:
type: "string"
language:
type: "array"
items:
type: "string"
identifier:
type: "array"
items:
type: "string"
based_near:
type: "array"
items:
type: "string"
related_url:
type: "array"
items:
type: "string"
sub_work_type:
type: "string"
enum:
- Capstone Course Work Product
- Capstone Project
- Culminating Research Project
- Doctor of Nursing Practice Project
- Integrative Doctoral Research Project
- Praxis Project
- Public Performance
- Scholarly Paper/Essay (MA/MS)
example: "Capstone Project"
program:
type: "string"
example: "Acoustics"
degree:
type: "string"
enum:
- Doctor of Education
- Doctor of Musical Arts
- Doctor of Nursing Practice
- Doctor of Public Health
- Doctor of Philosophy
- Master of Arts
- Master of Science
example: "Master of Science"
source:
type: "array"
items:
type: "string"
creators:
type: "array"
items:
$ref: "#/components/schemas/creator"
contributor:
type: "array"
items:
type: "string"
example: ["Dr. Phyllis Abracadabra", "Harry L. Snethers"]
rights:
type: "string"
enum:
- https://creativecommons.org/licenses/by/4.0/
- https://creativecommons.org/licenses/by-sa/4.0/
- https://creativecommons.org/licenses/by-nc/4.0/
- https://creativecommons.org/licenses/by-nd/4.0/
- https://creativecommons.org/licenses/by-nc-nd/4.0/
- https://creativecommons.org/licenses/by-nc-sa/4.0/
- http://creativecommons.org/publicdomain/mark/1.0/
- http://creativecommons.org/publicdomain/zero/1.0/
- https://rightsstatements.org/page/InC/1.0/
- http://www.apache.org/licenses/LICENSE-2.0
- https://www.gnu.org/licenses/gpl.html
- https://opensource.org/licenses/MIT
- https://opensource.org/licenses/BSD-3-Clause
example: "https://creativecommons.org/licenses/by/4.0/"
visibility:
type: "string"
enum:
- open
- authenticated
embargoed_until:
type: "string"
format: "date"
version_name:
type: "string"
example: "1.0.0"
description: "Must be in semantic version format. See https://semver.org/"
doi:
type: "string"
example: "doi:10.26207/002c-bb83"
description: >-
A DOI minted under Scholarsphere's current prefix, 10.26207. If you have another DOI that was previously
supplied by a publisher or someone else, that can be put into the identifier field.
creator:
type: "object"
required:
- "display_name"
properties:
display_name:
type: "string"
example: "Dr. Pat Researcher"
surname:
type: "string"
example: "Researcher"
given_name:
type: "string"
example: "Pat"
email:
type: "string"
example: "[email protected]"
psu_id:
type: "string"
example: "axb123"
orcid:
type: "string"
example: "0000-0000-1234-123X"
ingest:
type: "object"
required:
- "metadata"
- "depositor"
- "content"
properties:
metadata:
$ref: "#/components/schemas/metadata"
content:
type: "array"
description: >-
Files that have been uploaded to S3 in a previous step. The location information for each one, as well as
their original names and mime types, is included here.
items:
$ref: "#/components/schemas/uploadedFile"
depositor:
type: "string"
exmample: "axc123"
description: >-
The Penn State access of the person who is depositing the work. This is typically the same person who is the
creator, but not always. There is no restriction regarding who the depositor is other than they must have an
active account in Penn State's identity management system.
permissions:
$ref: "#/components/schemas/permissions"
uploads:
type: "object"
required:
- "extension"
- "content_md5"
properties:
extension:
type: "string"
description: >-
Three-letter file extension of the file your are requesting to upload into S3. This is used to created a
unique filename for the file in S3.
content_md5:
type: "string"
description: >-
Binary encoded md5 checksum of the file you are requesting to upload into S3. This is required so that we
can verify the integrity of the file when it is uploaded into S3.
uploadedFile:
type: "object"
permissions:
type: "object"
description: >-
Additional permissions for the work such as users or groups that can edit work. By default, only the depositor
may edit the work after it has been uploaded.
featuredResource:
allOf:
- $ref: "#/components/schemas/uuid"
- type: 'object'
required:
- 'uuid'
errorResponse:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
errors:
type: "array"
items:
type: "string"
fileMetadata:
required:
- 'id'
properties:
id:
$ref: "#/components/schemas/id"
metadata:
allOf:
- $ref: "#/components/schemas/virusCheck"
successResponse:
required:
- message
properties:
message:
type: string
virusCheck:
properties:
status:
type: "string"
format: 'boolean'
enum:
- true
- false
scanned_at:
type: "string"
format: 'date'
securitySchemes:
APIKey:
type: "apiKey"
description: >-
Key-based authorization mechanism to the API. A key is obtained fron the ScholarSphere team and is included in
the header of all requests.
name: "X_API_KEY"
in: "header"
responses:
defaultPostError:
description: >-
If the resource can't be created, then there is some kind of error. The client can interpret the responses.
content:
application/json:
schema:
$ref: "#/components/schemas/errorResponse"
examples:
unauthorized:
$ref: "#/components/examples/unauthorized"
notFound:
$ref: "#/components/examples/notFound"
unprocessableEntity:
$ref: "#/components/examples/unprocessableEntity"
serverError:
$ref: "#/components/examples/serverError"
examples:
unauthorized:
summary: "The client is not authorized to perform the requested action"
value:
code: 401
message: "401: Request not authorized. Please provide a valid API key for access."
notFound:
summary: "The requested resource does not exist"
value:
code: 404
message: "Record not found"
unprocessableEntity:
summary: "The request has missing or incorrect information"
value:
code: 411
message: "Unable to complete the request"
errors:
- "Sample error from server"
serverError:
summary: "The server threw some kind of error or exception"
value:
code: 500
message: "We're sorry, but something went wrong"
errors:
- "NoMethodError"
- "undefined method `application' for nil:NilClass"