datacite 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +118 -17
- data/README.md +20 -0
- data/datacite.gemspec +2 -0
- data/lib/datacite/mapping/from_cocina/alternate_identifiers.rb +30 -0
- data/lib/datacite/mapping/from_cocina/attributes.rb +74 -0
- data/lib/datacite/mapping/from_cocina/contributor_attributes.rb +209 -0
- data/lib/datacite/mapping/from_cocina/date.rb +198 -0
- data/lib/datacite/mapping/from_cocina/descriptions.rb +41 -0
- data/lib/datacite/mapping/from_cocina/identifiers.rb +28 -0
- data/lib/datacite/mapping/from_cocina/related_resource.rb +168 -0
- data/lib/datacite/mapping/from_cocina/rights_list.rb +36 -0
- data/lib/datacite/mapping/from_cocina/subject.rb +68 -0
- data/lib/datacite/mapping/from_cocina/titles.rb +32 -0
- data/lib/datacite/mapping/from_cocina/types.rb +81 -0
- data/lib/datacite/schema/datacite-v4.6.json +643 -0
- data/lib/datacite/validators/attributes_validator.rb +43 -0
- data/lib/datacite/validators/cocina_validator.rb +26 -0
- data/lib/datacite/version.rb +1 -1
- metadata +45 -3
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
|
3
|
+
"id": "datacite-v4.6.json",
|
|
4
|
+
"title": "DataCite v4.6",
|
|
5
|
+
"description": "JSON representation of the DataCite v4.6 schema.",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"definitions": {
|
|
8
|
+
"nameType": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"enum": [
|
|
11
|
+
"Organizational",
|
|
12
|
+
"Personal"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"nameIdentifiers": {
|
|
16
|
+
"type": "array",
|
|
17
|
+
"items": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"additionalProperties": false,
|
|
20
|
+
"properties": {
|
|
21
|
+
"nameIdentifier": {"type": "string"},
|
|
22
|
+
"nameIdentifierScheme": {"type": "string"},
|
|
23
|
+
"schemeUri": {"type": "string", "format": "uri"}
|
|
24
|
+
},
|
|
25
|
+
"required": ["nameIdentifier", "nameIdentifierScheme"]
|
|
26
|
+
},
|
|
27
|
+
"uniqueItems": true
|
|
28
|
+
},
|
|
29
|
+
"affiliation": {
|
|
30
|
+
"type": "array",
|
|
31
|
+
"items": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"additionalProperties": false,
|
|
34
|
+
"properties": {
|
|
35
|
+
"name": {"type": "string"},
|
|
36
|
+
"affiliationIdentifier": {"type": "string"},
|
|
37
|
+
"affiliationIdentifierScheme": {"type": "string"},
|
|
38
|
+
"schemeUri": {"type": "string", "format": "uri"}
|
|
39
|
+
},
|
|
40
|
+
"required": ["name"]
|
|
41
|
+
},
|
|
42
|
+
"uniqueItems": true
|
|
43
|
+
},
|
|
44
|
+
"person": {
|
|
45
|
+
"type": "object",
|
|
46
|
+
"properties": {
|
|
47
|
+
"name": {"type": "string"},
|
|
48
|
+
"nameType": {"$ref": "#/definitions/nameType"},
|
|
49
|
+
"givenName": {"type": "string"},
|
|
50
|
+
"familyName": {"type": "string"},
|
|
51
|
+
"nameIdentifiers": {"$ref": "#/definitions/nameIdentifiers"},
|
|
52
|
+
"affiliation": {"$ref": "#/definitions/affiliation"},
|
|
53
|
+
"lang": {"type": "string"}
|
|
54
|
+
},
|
|
55
|
+
"required": ["name"]
|
|
56
|
+
},
|
|
57
|
+
"creator": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"allOf": [{ "$ref": "#/definitions/person" }],
|
|
60
|
+
"unevaluatedProperties": false
|
|
61
|
+
},
|
|
62
|
+
"contributor": {
|
|
63
|
+
"type": "object",
|
|
64
|
+
"allOf": [{ "$ref": "#/definitions/person" }],
|
|
65
|
+
"unevaluatedProperties": false,
|
|
66
|
+
"properties": {
|
|
67
|
+
"contributorType": {"$ref": "#/definitions/contributorType"}
|
|
68
|
+
},
|
|
69
|
+
"required": ["name", "contributorType"]
|
|
70
|
+
},
|
|
71
|
+
"contributorType": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"enum": [
|
|
74
|
+
"ContactPerson",
|
|
75
|
+
"DataCollector",
|
|
76
|
+
"DataCurator",
|
|
77
|
+
"DataManager",
|
|
78
|
+
"Distributor",
|
|
79
|
+
"Editor",
|
|
80
|
+
"HostingInstitution",
|
|
81
|
+
"Producer",
|
|
82
|
+
"ProjectLeader",
|
|
83
|
+
"ProjectManager",
|
|
84
|
+
"ProjectMember",
|
|
85
|
+
"RegistrationAgency",
|
|
86
|
+
"RegistrationAuthority",
|
|
87
|
+
"RelatedPerson",
|
|
88
|
+
"Researcher",
|
|
89
|
+
"ResearchGroup",
|
|
90
|
+
"RightsHolder",
|
|
91
|
+
"Sponsor",
|
|
92
|
+
"Supervisor",
|
|
93
|
+
"WorkPackageLeader",
|
|
94
|
+
"Other"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
"titleType": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"enum": [
|
|
100
|
+
"AlternativeTitle",
|
|
101
|
+
"Subtitle",
|
|
102
|
+
"TranslatedTitle",
|
|
103
|
+
"Other"
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
"longitude": {
|
|
107
|
+
"type": "number",
|
|
108
|
+
"maximum": 180,
|
|
109
|
+
"minimum": -180
|
|
110
|
+
},
|
|
111
|
+
"latitude": {
|
|
112
|
+
"type": "number",
|
|
113
|
+
"maximum": 90,
|
|
114
|
+
"minimum": -90
|
|
115
|
+
},
|
|
116
|
+
"date": {
|
|
117
|
+
"type": "string",
|
|
118
|
+
"anyOf": [
|
|
119
|
+
{"format": "year"},
|
|
120
|
+
{"format": "yearmonth"},
|
|
121
|
+
{"format": "date"},
|
|
122
|
+
{"format": "datetime"},
|
|
123
|
+
{"format": "year-range"},
|
|
124
|
+
{"format": "yearmonth-range"},
|
|
125
|
+
{"format": "date-range"},
|
|
126
|
+
{"format": "datetime-range"}
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
"dateType": {
|
|
130
|
+
"type": "string",
|
|
131
|
+
"enum": [
|
|
132
|
+
"Accepted",
|
|
133
|
+
"Available",
|
|
134
|
+
"Copyrighted",
|
|
135
|
+
"Collected",
|
|
136
|
+
"Created",
|
|
137
|
+
"Issued",
|
|
138
|
+
"Submitted",
|
|
139
|
+
"Updated",
|
|
140
|
+
"Valid",
|
|
141
|
+
"Withdrawn",
|
|
142
|
+
"Other"
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
"resourceTypeGeneral": {
|
|
146
|
+
"type": "string",
|
|
147
|
+
"enum": [
|
|
148
|
+
"Audiovisual",
|
|
149
|
+
"Book",
|
|
150
|
+
"BookChapter",
|
|
151
|
+
"Collection",
|
|
152
|
+
"ComputationalNotebook",
|
|
153
|
+
"ConferencePaper",
|
|
154
|
+
"ConferenceProceeding",
|
|
155
|
+
"DataPaper",
|
|
156
|
+
"Dataset",
|
|
157
|
+
"Dissertation",
|
|
158
|
+
"Event",
|
|
159
|
+
"Image",
|
|
160
|
+
"Instrument",
|
|
161
|
+
"InteractiveResource",
|
|
162
|
+
"Journal",
|
|
163
|
+
"JournalArticle",
|
|
164
|
+
"Model",
|
|
165
|
+
"OutputManagementPlan",
|
|
166
|
+
"PeerReview",
|
|
167
|
+
"PhysicalObject",
|
|
168
|
+
"Preprint",
|
|
169
|
+
"Report",
|
|
170
|
+
"Service",
|
|
171
|
+
"Software",
|
|
172
|
+
"Sound",
|
|
173
|
+
"Standard",
|
|
174
|
+
"StudyRegistration",
|
|
175
|
+
"Text",
|
|
176
|
+
"Workflow",
|
|
177
|
+
"Other"
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
"relatedIdentifierType": {
|
|
181
|
+
"type": "string",
|
|
182
|
+
"enum": [
|
|
183
|
+
"ARK",
|
|
184
|
+
"arXiv",
|
|
185
|
+
"bibcode",
|
|
186
|
+
"DOI",
|
|
187
|
+
"EAN13",
|
|
188
|
+
"EISSN",
|
|
189
|
+
"Handle",
|
|
190
|
+
"IGSN",
|
|
191
|
+
"ISBN",
|
|
192
|
+
"ISSN",
|
|
193
|
+
"ISTC",
|
|
194
|
+
"LISSN",
|
|
195
|
+
"LSID",
|
|
196
|
+
"PMID",
|
|
197
|
+
"PURL",
|
|
198
|
+
"UPC",
|
|
199
|
+
"URL",
|
|
200
|
+
"URN",
|
|
201
|
+
"w3id"
|
|
202
|
+
]
|
|
203
|
+
},
|
|
204
|
+
"relationType": {
|
|
205
|
+
"type": "string",
|
|
206
|
+
"enum": [
|
|
207
|
+
"IsCitedBy",
|
|
208
|
+
"Cites",
|
|
209
|
+
"IsCollectedBy",
|
|
210
|
+
"Collects",
|
|
211
|
+
"IsSupplementTo",
|
|
212
|
+
"IsSupplementedBy",
|
|
213
|
+
"IsContinuedBy",
|
|
214
|
+
"Continues",
|
|
215
|
+
"IsDescribedBy",
|
|
216
|
+
"Describes",
|
|
217
|
+
"HasMetadata",
|
|
218
|
+
"IsMetadataFor",
|
|
219
|
+
"HasVersion",
|
|
220
|
+
"IsVersionOf",
|
|
221
|
+
"IsNewVersionOf",
|
|
222
|
+
"IsPartOf",
|
|
223
|
+
"IsPreviousVersionOf",
|
|
224
|
+
"IsPublishedIn",
|
|
225
|
+
"HasPart",
|
|
226
|
+
"IsReferencedBy",
|
|
227
|
+
"References",
|
|
228
|
+
"IsDocumentedBy",
|
|
229
|
+
"Documents",
|
|
230
|
+
"IsCompiledBy",
|
|
231
|
+
"Compiles",
|
|
232
|
+
"IsVariantFormOf",
|
|
233
|
+
"IsOriginalFormOf",
|
|
234
|
+
"IsIdenticalTo",
|
|
235
|
+
"IsReviewedBy",
|
|
236
|
+
"Reviews",
|
|
237
|
+
"IsDerivedFrom",
|
|
238
|
+
"IsSourceOf",
|
|
239
|
+
"IsRequiredBy",
|
|
240
|
+
"Requires",
|
|
241
|
+
"IsObsoletedBy",
|
|
242
|
+
"Obsoletes"
|
|
243
|
+
]
|
|
244
|
+
},
|
|
245
|
+
"relatedObject": {
|
|
246
|
+
"type": "object",
|
|
247
|
+
"properties": {
|
|
248
|
+
"relationType": {"$ref": "#/definitions/relationType"},
|
|
249
|
+
"relatedMetadataScheme": {"type": "string"},
|
|
250
|
+
"schemeUri": {"type": "string", "format": "uri"},
|
|
251
|
+
"schemeType": {"type": "string"},
|
|
252
|
+
"resourceTypeGeneral": {"$ref": "#/definitions/resourceTypeGeneral"}
|
|
253
|
+
},
|
|
254
|
+
"required": ["relationType"]
|
|
255
|
+
},
|
|
256
|
+
"relatedObjectIf": {
|
|
257
|
+
"properties": {
|
|
258
|
+
"relationType": {"enum": ["HasMetadata", "IsMetadataFor"]}
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
"relatedObjectElse": {
|
|
262
|
+
"$comment": "these properties may only be used with relation types HasMetadata/IsMetadataFor",
|
|
263
|
+
"properties": {
|
|
264
|
+
"relatedMetadataScheme": false,
|
|
265
|
+
"schemeUri": false,
|
|
266
|
+
"schemeType": false
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
"descriptionType": {
|
|
270
|
+
"type": "string",
|
|
271
|
+
"enum": [
|
|
272
|
+
"Abstract",
|
|
273
|
+
"Methods",
|
|
274
|
+
"SeriesInformation",
|
|
275
|
+
"TableOfContents",
|
|
276
|
+
"TechnicalInfo",
|
|
277
|
+
"Other"
|
|
278
|
+
]
|
|
279
|
+
},
|
|
280
|
+
"geoLocationPoint": {
|
|
281
|
+
"type": "object",
|
|
282
|
+
"additionalProperties": false,
|
|
283
|
+
"properties": {
|
|
284
|
+
"pointLongitude": {"$ref": "#/definitions/longitude"},
|
|
285
|
+
"pointLatitude": {"$ref": "#/definitions/latitude"}
|
|
286
|
+
},
|
|
287
|
+
"required": ["pointLongitude", "pointLatitude"]
|
|
288
|
+
},
|
|
289
|
+
"funderIdentifierType": {
|
|
290
|
+
"type": "string",
|
|
291
|
+
"enum": [
|
|
292
|
+
"ISNI",
|
|
293
|
+
"GRID",
|
|
294
|
+
"Crossref Funder ID",
|
|
295
|
+
"ROR",
|
|
296
|
+
"Other"
|
|
297
|
+
]
|
|
298
|
+
},
|
|
299
|
+
"publicationYear": {
|
|
300
|
+
"type": "string",
|
|
301
|
+
"pattern": "^[0-9]{4}$"
|
|
302
|
+
},
|
|
303
|
+
"identifier": {
|
|
304
|
+
"type": "object",
|
|
305
|
+
"properties": {
|
|
306
|
+
"identifier": {"type": "string"},
|
|
307
|
+
"identifierType": {
|
|
308
|
+
"type": "string",
|
|
309
|
+
"enum": [
|
|
310
|
+
"DOI"
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
"required": ["identifier", "identifierType"]
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
"type": "object",
|
|
318
|
+
"properties": {
|
|
319
|
+
"doi": {"type": "string", "pattern" : "^10[.][0-9]{4,9}[/][^\\s]+$"},
|
|
320
|
+
"prefix":{"type": "string", "pattern": "^10[.][0-9]{4,9}$"},
|
|
321
|
+
"suffix":{"type": "string", "pattern": "^[^\\s]+$"},
|
|
322
|
+
"event" : {
|
|
323
|
+
"type": "string",
|
|
324
|
+
"enum": [
|
|
325
|
+
"hide",
|
|
326
|
+
"register",
|
|
327
|
+
"publish"
|
|
328
|
+
]
|
|
329
|
+
},
|
|
330
|
+
"url": {"type": "string", "format": "uri"},
|
|
331
|
+
"identifiers": {
|
|
332
|
+
"type": "array",
|
|
333
|
+
"additionalProperties": false,
|
|
334
|
+
"items": {
|
|
335
|
+
"type": "object",
|
|
336
|
+
"allOf": [{ "$ref": "#/definitions/identifier" }]
|
|
337
|
+
},
|
|
338
|
+
"uniqueItems": true
|
|
339
|
+
},
|
|
340
|
+
"creators": {
|
|
341
|
+
"type": "array",
|
|
342
|
+
"items": {
|
|
343
|
+
"type": "object",
|
|
344
|
+
"allOf": [{ "$ref": "#/definitions/creator" }],
|
|
345
|
+
"required": ["name"]
|
|
346
|
+
},
|
|
347
|
+
"minItems": 1
|
|
348
|
+
},
|
|
349
|
+
"titles": {
|
|
350
|
+
"type": "array",
|
|
351
|
+
"items": {
|
|
352
|
+
"type": "object",
|
|
353
|
+
"additionalProperties": false,
|
|
354
|
+
"properties": {
|
|
355
|
+
"title": {"type": "string"},
|
|
356
|
+
"titleType": {"$ref": "#/definitions/titleType"},
|
|
357
|
+
"lang": {"type": "string"}
|
|
358
|
+
},
|
|
359
|
+
"required": ["title"]
|
|
360
|
+
},
|
|
361
|
+
"minItems": 1,
|
|
362
|
+
"uniqueItems": true
|
|
363
|
+
},
|
|
364
|
+
"publisher": {
|
|
365
|
+
"type": "object",
|
|
366
|
+
"additionalProperties": false,
|
|
367
|
+
"properties": {
|
|
368
|
+
"name": {"type":"string"},
|
|
369
|
+
"publisherIdentifier": {"type":"string"},
|
|
370
|
+
"publisherIdentifierScheme": {"type":"string"},
|
|
371
|
+
"schemeUri": {"type":"string", "format": "uri"},
|
|
372
|
+
"lang": {"type":"string"}
|
|
373
|
+
},
|
|
374
|
+
"required": ["name"]
|
|
375
|
+
},
|
|
376
|
+
"publicationYear": {"$ref": "#/definitions/publicationYear"},
|
|
377
|
+
"subjects": {
|
|
378
|
+
"type": "array",
|
|
379
|
+
"items": {
|
|
380
|
+
"type": "object",
|
|
381
|
+
"additionalProperties": false,
|
|
382
|
+
"properties": {
|
|
383
|
+
"subject": {"type": "string"},
|
|
384
|
+
"subjectScheme": {"type": "string"},
|
|
385
|
+
"schemeUri": {"type": "string", "format": "uri"},
|
|
386
|
+
"valueUri": {"type": "string", "format": "uri"},
|
|
387
|
+
"classificationCode": {"type": "string"},
|
|
388
|
+
"lang": {"type": "string"}
|
|
389
|
+
},
|
|
390
|
+
"required": ["subject"]
|
|
391
|
+
},
|
|
392
|
+
"uniqueItems": true
|
|
393
|
+
},
|
|
394
|
+
"contributors": {
|
|
395
|
+
"type": "array",
|
|
396
|
+
"items": {
|
|
397
|
+
"type": "object",
|
|
398
|
+
"allOf": [{ "$ref": "#/definitions/contributor" }],
|
|
399
|
+
"required": ["contributorType", "name"]
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
"dates": {
|
|
403
|
+
"type": "array",
|
|
404
|
+
"items": {
|
|
405
|
+
"type": "object",
|
|
406
|
+
"additionalProperties": false,
|
|
407
|
+
"properties": {
|
|
408
|
+
"date": {"$ref": "#/definitions/date"},
|
|
409
|
+
"dateType": {"$ref": "#/definitions/dateType"},
|
|
410
|
+
"dateInformation": {"type": "string"}
|
|
411
|
+
},
|
|
412
|
+
"required": ["date", "dateType"]
|
|
413
|
+
},
|
|
414
|
+
"uniqueItems": true
|
|
415
|
+
},
|
|
416
|
+
"language": {
|
|
417
|
+
"type": "string",
|
|
418
|
+
"$comment": "Primary language of the resource. Allowed values are taken from IETF BCP 47, ISO 639-1 language codes."
|
|
419
|
+
},
|
|
420
|
+
"types": {
|
|
421
|
+
"type": "object",
|
|
422
|
+
"additionalProperties": false,
|
|
423
|
+
"properties": {
|
|
424
|
+
"resourceType": {"type": "string"},
|
|
425
|
+
"resourceTypeGeneral": {"$ref": "#/definitions/resourceTypeGeneral"}
|
|
426
|
+
},
|
|
427
|
+
"required": ["resourceTypeGeneral"]
|
|
428
|
+
},
|
|
429
|
+
"alternateIdentifiers": {
|
|
430
|
+
"type": "array",
|
|
431
|
+
"items": {
|
|
432
|
+
"type": "object",
|
|
433
|
+
"additionalProperties": false,
|
|
434
|
+
"properties": {
|
|
435
|
+
"alternateIdentifier": {"type": "string"},
|
|
436
|
+
"alternateIdentifierType": {"type": "string"}
|
|
437
|
+
},
|
|
438
|
+
"required": ["alternateIdentifier", "alternateIdentifierType"]
|
|
439
|
+
},
|
|
440
|
+
"uniqueItems": true
|
|
441
|
+
},
|
|
442
|
+
"relatedIdentifiers": {
|
|
443
|
+
"type": "array",
|
|
444
|
+
"items": {
|
|
445
|
+
"type": "object",
|
|
446
|
+
"allOf": [{ "$ref": "#/definitions/relatedObject"}],
|
|
447
|
+
"unevaluatedProperties": false,
|
|
448
|
+
"properties": {
|
|
449
|
+
"relatedIdentifier": {"type": "string"},
|
|
450
|
+
"relatedIdentifierType": {"$ref": "#/definitions/relatedIdentifierType"}
|
|
451
|
+
},
|
|
452
|
+
"required": ["relatedIdentifier", "relatedIdentifierType", "relationType"],
|
|
453
|
+
"if": {"$ref": "#/definitions/relatedObjectIf"},
|
|
454
|
+
"else": {"$ref": "#/definitions/relatedObjectElse"}
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
"sizes": {
|
|
458
|
+
"type": "array",
|
|
459
|
+
"items": {
|
|
460
|
+
"type": "string"
|
|
461
|
+
},
|
|
462
|
+
"uniqueItems": true
|
|
463
|
+
},
|
|
464
|
+
"formats": {
|
|
465
|
+
"type": "array",
|
|
466
|
+
"items": {
|
|
467
|
+
"type": "string"
|
|
468
|
+
},
|
|
469
|
+
"uniqueItems": true
|
|
470
|
+
},
|
|
471
|
+
"version": {
|
|
472
|
+
"type": "string"
|
|
473
|
+
},
|
|
474
|
+
"rightsList": {
|
|
475
|
+
"type": "array",
|
|
476
|
+
"items": {
|
|
477
|
+
"type": "object",
|
|
478
|
+
"additionalProperties": false,
|
|
479
|
+
"properties": {
|
|
480
|
+
"rights": {"type": "string"},
|
|
481
|
+
"rightsUri": {"type": "string", "format": "uri"},
|
|
482
|
+
"rightsIdentifier": {"type": "string"},
|
|
483
|
+
"rightsIdentifierScheme": {"type": "string"},
|
|
484
|
+
"schemeUri": {"type": "string", "format": "uri"},
|
|
485
|
+
"lang": {"type": "string"}
|
|
486
|
+
}
|
|
487
|
+
},
|
|
488
|
+
"uniqueItems": true
|
|
489
|
+
},
|
|
490
|
+
"descriptions": {
|
|
491
|
+
"type": "array",
|
|
492
|
+
"items": {
|
|
493
|
+
"type": "object",
|
|
494
|
+
"additionalProperties": false,
|
|
495
|
+
"properties": {
|
|
496
|
+
"description": {"type": "string"},
|
|
497
|
+
"descriptionType": {"$ref": "#/definitions/descriptionType"},
|
|
498
|
+
"lang": {"type": "string"}
|
|
499
|
+
},
|
|
500
|
+
"required": ["description", "descriptionType"]
|
|
501
|
+
},
|
|
502
|
+
"uniqueItems": true
|
|
503
|
+
},
|
|
504
|
+
"geoLocations": {
|
|
505
|
+
"type": "array",
|
|
506
|
+
"items": {
|
|
507
|
+
"type": "object",
|
|
508
|
+
"additionalProperties": false,
|
|
509
|
+
"properties": {
|
|
510
|
+
"geoLocationPlace": {"type": "string"},
|
|
511
|
+
"geoLocationPoint": {"$ref": "#/definitions/geoLocationPoint"},
|
|
512
|
+
"geoLocationBox": {
|
|
513
|
+
"type": "object",
|
|
514
|
+
"additionalProperties": false,
|
|
515
|
+
"properties": {
|
|
516
|
+
"westBoundLongitude": {"$ref": "#/definitions/longitude"},
|
|
517
|
+
"eastBoundLongitude": {"$ref": "#/definitions/longitude"},
|
|
518
|
+
"southBoundLatitude": {"$ref": "#/definitions/latitude"},
|
|
519
|
+
"northBoundLatitude": {"$ref": "#/definitions/latitude"}
|
|
520
|
+
},
|
|
521
|
+
"required": ["westBoundLongitude", "eastBoundLongitude", "southBoundLatitude", "northBoundLatitude"]
|
|
522
|
+
},
|
|
523
|
+
"geoLocationPolygon": {
|
|
524
|
+
"type": "array",
|
|
525
|
+
"items": {
|
|
526
|
+
"type": "object",
|
|
527
|
+
"additionalProperties": false,
|
|
528
|
+
"properties": {
|
|
529
|
+
"polygonPoint": {"$ref": "#/definitions/geoLocationPoint"},
|
|
530
|
+
"inPolygonPoint": {"$ref": "#/definitions/geoLocationPoint"}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
},
|
|
536
|
+
"uniqueItems": true
|
|
537
|
+
},
|
|
538
|
+
"fundingReferences": {
|
|
539
|
+
"type": "array",
|
|
540
|
+
"items": {
|
|
541
|
+
"type": "object",
|
|
542
|
+
"additionalProperties": false,
|
|
543
|
+
"properties": {
|
|
544
|
+
"funderName": {"type": "string"},
|
|
545
|
+
"funderIdentifier": {"type": "string"},
|
|
546
|
+
"funderIdentifierType": {"$ref": "#/definitions/funderIdentifierType"},
|
|
547
|
+
"awardNumber": {"type": "string"},
|
|
548
|
+
"awardUri": {"type": "string", "format": "uri"},
|
|
549
|
+
"awardTitle": {"type": "string"}
|
|
550
|
+
},
|
|
551
|
+
"required": ["funderName"]
|
|
552
|
+
},
|
|
553
|
+
"uniqueItems": true
|
|
554
|
+
},
|
|
555
|
+
"relatedItems": {
|
|
556
|
+
"type": "array",
|
|
557
|
+
"items": {
|
|
558
|
+
"type": "object",
|
|
559
|
+
"allOf": [{ "$ref": "#/definitions/relatedObject"}],
|
|
560
|
+
"unevaluatedProperties": false,
|
|
561
|
+
"properties": {
|
|
562
|
+
"relatedItemIdentifier": {
|
|
563
|
+
"type": "object",
|
|
564
|
+
"additionalProperties": false,
|
|
565
|
+
"properties": {
|
|
566
|
+
"relatedItemIdentifier": {"type": "string"},
|
|
567
|
+
"relatedItemIdentifierType": {"$ref": "#/definitions/relatedIdentifierType"}
|
|
568
|
+
},
|
|
569
|
+
"required": ["relatedItemIdentifier", "relatedItemIdentifierType"]
|
|
570
|
+
},
|
|
571
|
+
"relatedItemType": {"$ref": "#/definitions/resourceTypeGeneral"},
|
|
572
|
+
"creators": {
|
|
573
|
+
"type": "array",
|
|
574
|
+
"items": {
|
|
575
|
+
"type": "object",
|
|
576
|
+
"unevaluatedProperties": false,
|
|
577
|
+
"allOf": [{ "$ref": "#/definitions/creator" }],
|
|
578
|
+
"required": ["name"]
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
"contributors": {
|
|
582
|
+
"type": "array",
|
|
583
|
+
"items": {
|
|
584
|
+
"type": "object",
|
|
585
|
+
"unevaluatedProperties": false,
|
|
586
|
+
"allOf": [{ "$ref": "#/definitions/contributor" }],
|
|
587
|
+
"required": ["contributorType", "name"]
|
|
588
|
+
}
|
|
589
|
+
},
|
|
590
|
+
"titles": {
|
|
591
|
+
"type": "array",
|
|
592
|
+
"items": {
|
|
593
|
+
"type": "object",
|
|
594
|
+
"additionalProperties": false,
|
|
595
|
+
"properties": {
|
|
596
|
+
"title": {"type": "string"},
|
|
597
|
+
"titleType": {"$ref": "#/definitions/titleType"},
|
|
598
|
+
"lang": {"type": "string"}
|
|
599
|
+
},
|
|
600
|
+
"required": ["title"]
|
|
601
|
+
},
|
|
602
|
+
"minItems": 1,
|
|
603
|
+
"uniqueItems": true
|
|
604
|
+
},
|
|
605
|
+
"publicationYear": {"$ref": "#/definitions/publicationYear"},
|
|
606
|
+
"volume": {"type": "string"},
|
|
607
|
+
"issue": {"type": "string"},
|
|
608
|
+
"firstPage": {"type": "string"},
|
|
609
|
+
"lastPage": {"type": "string"},
|
|
610
|
+
"edition": {"type": "string"},
|
|
611
|
+
"publisher": {"type": "string"},
|
|
612
|
+
"number": {"type":"string"},
|
|
613
|
+
"numberType": {
|
|
614
|
+
"type": "string",
|
|
615
|
+
"enum": [
|
|
616
|
+
"Article",
|
|
617
|
+
"Chapter",
|
|
618
|
+
"Report",
|
|
619
|
+
"Other"
|
|
620
|
+
]
|
|
621
|
+
}
|
|
622
|
+
},
|
|
623
|
+
"required": ["titles", "relatedItemType", "relationType"],
|
|
624
|
+
"if": {"$ref": "#/definitions/relatedObjectIf"},
|
|
625
|
+
"else": {"$ref": "#/definitions/relatedObjectElse"}
|
|
626
|
+
},
|
|
627
|
+
"uniqueItems": true
|
|
628
|
+
},
|
|
629
|
+
"schemaVersion": {
|
|
630
|
+
"type": "string",
|
|
631
|
+
"const": "http://datacite.org/schema/kernel-4"
|
|
632
|
+
}
|
|
633
|
+
},
|
|
634
|
+
"required": [
|
|
635
|
+
"identifiers",
|
|
636
|
+
"creators",
|
|
637
|
+
"titles",
|
|
638
|
+
"publisher",
|
|
639
|
+
"publicationYear",
|
|
640
|
+
"types",
|
|
641
|
+
"schemaVersion"
|
|
642
|
+
]
|
|
643
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json_schemer'
|
|
4
|
+
require 'pathname'
|
|
5
|
+
|
|
6
|
+
module Datacite
|
|
7
|
+
module Validators
|
|
8
|
+
# Validate a hash of attributes against the DataCite schema
|
|
9
|
+
class AttributesValidator
|
|
10
|
+
# @param [Hash] attributes for a DataCite API request
|
|
11
|
+
def initialize(attributes:)
|
|
12
|
+
@attributes = attributes
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @return [Boolean] true if valid, false if not
|
|
16
|
+
def valid?
|
|
17
|
+
results.none? # If there are no results (an Enumerator), there were no errors, thus valid
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def errors
|
|
21
|
+
results.map { |result| result.fetch('error') }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
attr_reader :attributes
|
|
27
|
+
|
|
28
|
+
def results
|
|
29
|
+
@results ||= schema.validate(attributes)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def schema
|
|
33
|
+
@schema ||= JSONSchemer.schema(schema_path)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# This schema file was borrowed from https://github.com/inveniosoftware/datacite/blob/master/datacite/schemas/datacite-v4.5.json
|
|
37
|
+
# and adapted to add the `identifiers` block to comply with v4.6 of the schema.
|
|
38
|
+
def schema_path
|
|
39
|
+
Pathname.new(File.expand_path('../schema/datacite-v4.6.json', __dir__))
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|