From 4929fca2495ff15cb5c224177cff65946ea5f789 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 1 Nov 2024 12:15:45 -0400 Subject: [PATCH 1/6] Add "version" to datacite record folded in a typo fix --- dandischema/datacite.py | 2 ++ dandischema/tests/test_datacite.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dandischema/datacite.py b/dandischema/datacite.py index f8a42469..13b1766f 100644 --- a/dandischema/datacite.py +++ b/dandischema/datacite.py @@ -83,6 +83,8 @@ def to_datacite( ] attributes["doi"] = meta.doi + if meta.version: + attributes["version"] = meta.version attributes["titles"] = [{"title": meta.name}] attributes["descriptions"] = [ {"description": meta.description, "descriptionType": "Abstract"} diff --git a/dandischema/tests/test_datacite.py b/dandischema/tests/test_datacite.py index 7c682b80..8ed971e3 100644 --- a/dandischema/tests/test_datacite.py +++ b/dandischema/tests/test_datacite.py @@ -422,7 +422,7 @@ def test_dandimeta_datacite( else: assert attr[key] == el_flds - # trying to poste datacite + # trying to post to datacite datacite_post(datacite, metadata_basic["doi"]) @@ -433,7 +433,7 @@ def test_datacite_publish(metadata_basic: Dict[str, Any]) -> None: metadata_basic.update(_basic_publishmeta(dandi_id=dandi_id_noprefix)) # creating and validating datacite objects - datacite = to_datacite(metadata_basic, publish=True) + datacite = to_datacite(metadata_basic, publish=True, validate=True) assert datacite == { # 'data': {} @@ -505,6 +505,7 @@ def test_datacite_publish(metadata_basic: Dict[str, Any]) -> None: "resourceTypeGeneral": "Dataset", }, "url": f"https://dandiarchive.org/dandiset/{dandi_id_noprefix}/{version}", + "version": version, }, } } From e077468b8fb63d0f829c871d926d09d30863cd74 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 4 Nov 2024 10:21:21 -0500 Subject: [PATCH 2/6] Make datacite into a submodule --- dandischema/{datacite.py => datacite/__init__.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename dandischema/{datacite.py => datacite/__init__.py} (100%) diff --git a/dandischema/datacite.py b/dandischema/datacite/__init__.py similarity index 100% rename from dandischema/datacite.py rename to dandischema/datacite/__init__.py From 5037f4c177584eaacdf42beaa9b38e409b6a095f Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 4 Nov 2024 10:22:18 -0500 Subject: [PATCH 3/6] Add header to datacite submodule --- dandischema/datacite/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dandischema/datacite/__init__.py b/dandischema/datacite/__init__.py index 13b1766f..40f90d95 100644 --- a/dandischema/datacite/__init__.py +++ b/dandischema/datacite/__init__.py @@ -1,3 +1,9 @@ +""" +Interfaces and data to interact with DataCite metadata +""" + +# TODO: RF into submodules for some next "minor" taking care not to break + from copy import deepcopy import re from typing import Any, Dict, Union From 5741d283b59f019fef4b9cbafff899b3ee9d5bfa Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 4 Nov 2024 10:49:56 -0500 Subject: [PATCH 4/6] ENH: bundle all known versions of datacite json + switch to use the bundled one --- dandischema/datacite/__init__.py | 19 +- dandischema/datacite/schema/README.md | 48 ++ .../schema/datacite-4.3-17-gaa5db56.json | 490 ++++++++++++++ .../schema/datacite-4.3-72-g732cc7e.json | 505 ++++++++++++++ .../inveniosoftware-4.3-66-g24fc2ba.json | 495 ++++++++++++++ .../inveniosoftware-4.5-81-g160250d.json | 628 ++++++++++++++++++ 6 files changed, 2175 insertions(+), 10 deletions(-) create mode 100644 dandischema/datacite/schema/README.md create mode 100644 dandischema/datacite/schema/datacite-4.3-17-gaa5db56.json create mode 100644 dandischema/datacite/schema/datacite-4.3-72-g732cc7e.json create mode 100644 dandischema/datacite/schema/inveniosoftware-4.3-66-g24fc2ba.json create mode 100644 dandischema/datacite/schema/inveniosoftware-4.5-81-g160250d.json diff --git a/dandischema/datacite/__init__.py b/dandischema/datacite/__init__.py index 40f90d95..57423823 100644 --- a/dandischema/datacite/__init__.py +++ b/dandischema/datacite/__init__.py @@ -5,13 +5,16 @@ # TODO: RF into submodules for some next "minor" taking care not to break from copy import deepcopy +from functools import lru_cache +import json +from pathlib import Path import re from typing import Any, Dict, Union from jsonschema import Draft7Validator import requests -from .models import NAME_PATTERN, Organization, Person, PublishedDandiset, RoleType +from ..models import NAME_PATTERN, Organization, Person, PublishedDandiset, RoleType DATACITE_CONTRTYPE = { "ContactPerson", @@ -248,15 +251,11 @@ def to_datacite( return datacite_dict -def _get_datacite_schema() -> Any: - sr = requests.get( - "https://raw.githubusercontent.com/datacite/schema/" - "732cc7ef29f4cad4d6adfac83544133cd57a2e5e/" - "source/json/kernel-4.3/datacite_4.3_schema.json" - ) - sr.raise_for_status() - schema = sr.json() - return schema +@lru_cache() +def _get_datacite_schema(version_id: str = "datacite-4.3-17-gaa5db56") -> dict: + """Load datacite schema based on the version id provided.""" + schema_folder = Path(__file__).parent / "schema" + return json.loads((schema_folder / f"{version_id}.json").read_text()) def validate_datacite(datacite_dict: dict) -> None: diff --git a/dandischema/datacite/schema/README.md b/dandischema/datacite/schema/README.md new file mode 100644 index 00000000..f3dd0252 --- /dev/null +++ b/dandischema/datacite/schema/README.md @@ -0,0 +1,48 @@ +Folder contains copies of jsonschema serializations of datacite which were +initially kept within datacite repository, + + https://github.com/datacite/schema/tree/master/source/json + +but then moved to the "origin" of their manufacturing -- inveniosoftware + + https://github.com/inveniosoftware/datacite/tree/master/datacite/schemas + +Those serializations are not "scripted" and apparently produced manually. +Related issues/inquiries: + +- https://github.com/datacite/schema/issues/149 +- https://github.com/inveniosoftware/datacite/issues/101 + +Versions in the suffixes of the files here were produced based on +original version tag and output of git describe so we capture "order" within +MAJOR.MINOR versions. e.g. + + ❯ git describe --tags --match 4.3 732cc7 + 4.3-72-g732cc7e + ❯ git describe --tags --match 4.3 aa5db5 + 4.3-17-gaa5db56 + +for those from datacite, for the last one based on commit when was last +modified (not current master). In "inveniosoftware" there are no tags for +versions of datacite, so we base ordering of 0.1.0 first tag there: + + ❯ git log datacite-v4.3.json + commit 24fc2ba3ded44512ce8569dc11c958da4a29f70a + Author: Thorge Petersen + Date: Fri Aug 12 09:47:45 2022 +0200 + + schema: change affiliation definition to match property name + + commit dc8403fd8556858e8917b960b0721884c52a588e + Author: Tom Morrell + Date: Thu Aug 15 12:17:21 2019 -0700 + + schema: Add support for DataCite 4.3 metadata schema + + ❯ git describe --match v0.1.0 24fc2ba3ded44512ce8569dc11c958da4a29f70a + v0.1.0-66-g24fc2ba + +so we get + + ❯ cp /home/yoh/proj/datacite/inveniosoftware-datacite/datacite/schemas/datacite-v4.3.json inveniosoftware-4.3-66-g24fc2ba.json + ❯ cp /home/yoh/proj/datacite/inveniosoftware-datacite/datacite/schemas/datacite-v4.5.json inveniosoftware-4.5-81-g160250d.json diff --git a/dandischema/datacite/schema/datacite-4.3-17-gaa5db56.json b/dandischema/datacite/schema/datacite-4.3-17-gaa5db56.json new file mode 100644 index 00000000..a72f1b18 --- /dev/null +++ b/dandischema/datacite/schema/datacite-4.3-17-gaa5db56.json @@ -0,0 +1,490 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + + "definitions": { + "nameType": { + "type": "string", + "enum": [ + "Organizational", + "Personal" + ] + }, + "nameIdentifiers": { + "type": "array", + "items": { + "type": "object", + "properties": { + "nameIdentifier": {"type": "string"}, + "nameIdentifierScheme": {"type": "string"}, + "schemeURI": {"type": "string", "format": "uri"} + }, + "required": ["nameIdentifier", "nameIdentifierScheme"] + }, + "uniqueItems": true + }, + "affiliations": { + "type": "array", + "items": { + "type": "object", + "properties": { + "affiliation": {"type": "string"} + }, + "required": ["affiliation"] + }, + "uniqueItems": true + }, + "titleType": { + "type": "string", + "enum": [ + "AlternativeTitle", + "Subtitle", + "TranslatedTitle", + "Other" + ] + }, + "contributorType": { + "type": "string", + "enum": [ + "ContactPerson", + "DataCollector", + "DataCurator", + "DataManager", + "Distributor", + "Editor", + "HostingInstitution", + "Producer", + "ProjectLeader", + "ProjectManager", + "ProjectMember", + "RegistrationAgency", + "RegistrationAuthority", + "RelatedPerson", + "Researcher", + "ResearchGroup", + "RightsHolder", + "Sponsor", + "Supervisor", + "WorkPackageLeader", + "Other" + ] + }, + "date": { + "type": "string", + "anyOf": [ + {"format": "year"}, + {"format": "yearmonth"}, + {"format": "date"}, + {"format": "datetime"}, + {"format": "year-range"}, + {"format": "yearmonth-range"}, + {"format": "date-range"}, + {"format": "datetime-range"} + ] + }, + "dateType": { + "type": "string", + "enum": [ + "Accepted", + "Available", + "Copyrighted", + "Collected", + "Created", + "Issued", + "Submitted", + "Updated", + "Valid", + "Withdrawn", + "Other" + ] + }, + "resourceTypeGeneral": { + "type": "string", + "enum": [ + "Audiovisual", + "Collection", + "DataPaper", + "Dataset", + "Event", + "Image", + "InteractiveResource", + "Model", + "PhysicalObject", + "Service", + "Software", + "Sound", + "Text", + "Workflow", + "Other" + ] + }, + "relatedIdentifierType": { + "type": "string", + "enum": [ + "ARK", + "arXiv", + "bibcode", + "DOI", + "EAN13", + "EISSN", + "Handle", + "IGSN", + "ISBN", + "ISSN", + "ISTC", + "LISSN", + "LSID", + "PMID", + "PURL", + "UPC", + "URL", + "URN", + "w3id" + ] + }, + "relationType": { + "type": "string", + "enum": [ + "IsCitedBy", + "Cites", + "IsSupplementTo", + "IsSupplementedBy", + "IsContinuedBy", + "Continues", + "IsDescribedBy", + "Describes", + "HasMetadata", + "IsMetadataFor", + "HasVersion", + "IsVersionOf", + "IsNewVersionOf", + "IsPreviousVersionOf", + "IsPartOf", + "HasPart", + "IsReferencedBy", + "References", + "IsDocumentedBy", + "Documents", + "IsCompiledBy", + "Compiles", + "IsVariantFormOf", + "IsOriginalFormOf", + "IsIdenticalTo", + "IsReviewedBy", + "Reviews", + "IsDerivedFrom", + "IsSourceOf", + "IsRequiredBy", + "Requires", + "IsObsoletedBy", + "Obsoletes" + ] + }, + "descriptionType": { + "type": "string", + "enum": [ + "Abstract", + "Methods", + "SeriesInformation", + "TableOfContents", + "TechnicalInfo", + "Other" + ] + }, + "geoLocationPoint": { + "type": "object", + "properties": { + "pointLongitude": {"$ref": "#/definitions/longitude"}, + "pointLatitude": {"$ref": "#/definitions/latitude"} + }, + "required": ["pointLongitude", "pointLatitude"] + }, + "longitude": { + "type": "number", + "minimum": -180, + "maximum": 180 + }, + "latitude": { + "type": "number", + "minimum": -90, + "maximum": 90 + }, + "funderIdentifierType": { + "type": "string", + "enum": [ + "ISNI", + "GRID", + "Crossref Funder ID", + "Other" + ] + } + }, + + "type": "object", + + "properties": { + "types": { + "type": "object", + "properties": { + "resourceType": {"type": "string"}, + "resourceTypeGeneral": {"$ref": "#/definitions/resourceTypeGeneral"} + }, + "required": ["resourceType", "resourceTypeGeneral"] + }, + "identifiers": { + "type": "array", + "items":{ + "type": "object", + "properties": { + "identifier": {"type": "string"}, + "identifierType": {"type": "string"} + }, + "required": ["identifier", "identifierType"] + }, + "minItems": 1, + "uniqueItems": true + }, + "creators": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": {"type": "string"}, + "nameType": {"$ref": "#/definitions/nameType"}, + "givenName": {"type": "string"}, + "familyName": {"type": "string"}, + "nameIdentifiers": {"$ref": "#/definitions/nameIdentifiers"}, + "affiliations": {"$ref": "#/definitions/affiliations"}, + "lang": {"type": "string"} + }, + "required": ["name"] + }, + "minItems": 1, + "uniqueItems": true + }, + "titles": { + "type": "array", + "items": { + "type": "object", + "properties": { + "title": {"type": "string"}, + "titleType": {"$ref": "#/definitions/titleType"}, + "lang": {"type": "string"} + }, + "required": ["title"] + }, + "minItems": 1, + "uniqueItems": true + }, + "publisher": { + "type": "string" + }, + "publicationYear": { + "type": "string", + "format": "year" + }, + "subjects": { + "type": "array", + "items": { + "type": "object", + "properties": { + "subject": {"type": "string"}, + "subjectScheme": {"type": "string"}, + "schemeURI": {"type": "string", "format": "uri"}, + "valueURI": {"type": "string", "format": "uri"}, + "lang": {"type": "string"} + }, + "required": ["subject"] + }, + "uniqueItems": true + }, + "contributors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "contributorType": {"$ref": "#/definitions/contributorType"}, + "name": {"type": "string"}, + "nameType": {"$ref": "#/definitions/nameType"}, + "givenName": {"type": "string"}, + "familyName": {"type": "string"}, + "nameIdentifiers": {"$ref": "#/definitions/nameIdentifiers"}, + "affiliations": {"$ref": "#/definitions/affiliations"}, + "lang": {"type": "string"} + }, + "required": ["contributorType", "name"] + }, + "uniqueItems": true + }, + "dates": { + "type": "array", + "items": { + "type": "object", + "properties": { + "date": {"$ref": "#/definitions/date"}, + "dateType": {"$ref": "#/definitions/dateType"}, + "dateInformation": {"type": "string"} + }, + "required": ["date", "dateType"] + }, + "uniqueItems": true + }, + "language": { + "type": "string", + "$comment": "Primary language of the resource. Allowed values are taken from IETF BCP 47, ISO 639-1 language codes." + }, + "alternateIdentifiers": { + "type": "array", + "items": { + "type": "object", + "properties": { + "alternateIdentifier": {"type": "string"}, + "alternateIdentifierType": {"type": "string"} + }, + "required": ["alternateIdentifier", "alternateIdentifierType"] + }, + "uniqueItems": true + }, + "relatedIdentifiers": { + "type": "array", + "items": { + "type": "object", + "properties": { + "relatedIdentifier": {"type": "string"}, + "relatedIdentifierType": {"$ref": "#/definitions/relatedIdentifierType"}, + "relationType": {"$ref": "#/definitions/relationType"}, + "relatedMetadataScheme": {"type": "string"}, + "schemeURI": {"type": "string", "format": "uri"}, + "schemeType": {"type": "string"}, + "resourceTypeGeneral": {"$ref": "#/definitions/resourceTypeGeneral"} + }, + "required": ["relatedIdentifier", "relatedIdentifierType", "relationType"], + "if": { + "properties": { + "relationType": {"enum": ["HasMetadata", "IsMetadataFor"]} + } + }, + "else": { + "$comment": "these properties may only be used with relation types HasMetadata/IsMetadataFor", + "properties": { + "relatedMetadataScheme": false, + "schemeURI": false, + "schemeType": false + } + } + }, + "uniqueItems": true + }, + "sizes": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "formats": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "version": { + "type": "string" + }, + "rightsList": { + "type": "array", + "items": { + "type": "object", + "properties": { + "rights": {"type": "string"}, + "rightsURI": {"type": "string", "format": "uri"}, + "rightsIdentifier": {"type": "string"}, + "rightsIdentifierScheme": {"type": "string"}, + "schemeURI": {"type": "string", "format": "uri"}, + "lang": {"type": "string"} + } + }, + "uniqueItems": true + }, + "descriptions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "description": {"type": "string"}, + "descriptionType": {"$ref": "#/definitions/descriptionType"}, + "lang": {"type": "string"} + }, + "required": ["description", "descriptionType"] + }, + "uniqueItems": true + }, + "geoLocations": { + "type": "array", + "items": { + "type": "object", + "properties": { + "geoLocationPlace": {"type": "string"}, + "geoLocationPoint": {"$ref": "#/definitions/geoLocationPoint"}, + "geoLocationBox": { + "type": "object", + "properties": { + "westBoundLongitude": {"$ref": "#/definitions/longitude"}, + "eastBoundLongitude": {"$ref": "#/definitions/longitude"}, + "southBoundLatitude": {"$ref": "#/definitions/latitude"}, + "northBoundLatitude": {"$ref": "#/definitions/latitude"} + }, + "required": ["westBoundLongitude", "eastBoundLongitude", "southBoundLatitude", "northBoundLatitude"] + }, + "geoLocationPolygons": { + "type": "array", + "items": { + "type": "object", + "properties": { + "polygonPoints": { + "type": "array", + "items": {"$ref": "#/definitions/geoLocationPoint"}, + "minItems": 4 + }, + "inPolygonPoint": {"$ref": "#/definitions/geoLocationPoint"} + }, + "required": ["polygonPoints"] + }, + "uniqueItems": true + } + } + }, + "uniqueItems": true + }, + "fundingReferences": { + "type": "array", + "items": { + "type": "object", + "properties": { + "funderName": {"type": "string"}, + "funderIdentifier": {"type": "string"}, + "funderIdentifierType": {"$ref": "#/definitions/funderIdentifierType"}, + "awardNumber": {"type": "string"}, + "awardURI": {"type": "string", "format": "uri"}, + "awardTitle": {"type": "string"} + }, + "required": ["funderName"] + }, + "uniqueItems": true + }, + "schemaVersion": { + "type": "string", + "const": "http://datacite.org/schema/kernel-4" + } + }, + + "required": [ + "identifiers", + "creators", + "titles", + "publisher", + "publicationYear", + "types", + "schemaVersion" + ] +} diff --git a/dandischema/datacite/schema/datacite-4.3-72-g732cc7e.json b/dandischema/datacite/schema/datacite-4.3-72-g732cc7e.json new file mode 100644 index 00000000..cfaa7d9f --- /dev/null +++ b/dandischema/datacite/schema/datacite-4.3-72-g732cc7e.json @@ -0,0 +1,505 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "id": "datacite-v4.3.json", + "title": "DataCite v4.3", + "description": "JSON representation of the DataCite v4.3 schema.", + "additionalProperties": false, + "definitions": { + "nameType": { + "type": "string", + "enum": [ + "Organizational", + "Personal" + ] + }, + "nameIdentifiers": { + "type": "array", + "items": { + "type": "object", + "properties": { + "nameIdentifier": {"type": "string"}, + "nameIdentifierScheme": {"type": "string"}, + "schemeUri": {"type": "string", "format": "uri"} + }, + "required": ["nameIdentifier", "nameIdentifierScheme"] + }, + "uniqueItems": true + }, + "affiliations": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": {"type": "string"}, + "affiliationIdentifier": {"type": "string"}, + "affiliationIdentifierScheme": {"type": "string"}, + "schemeUri": {"type": "string", "format": "uri"} + }, + "required": ["name"] + }, + "uniqueItems": true + }, + "titleType": { + "type": "string", + "enum": [ + "AlternativeTitle", + "Subtitle", + "TranslatedTitle", + "Other" + ] + }, + "contributorType": { + "type": "string", + "enum": [ + "ContactPerson", + "DataCollector", + "DataCurator", + "DataManager", + "Distributor", + "Editor", + "HostingInstitution", + "Producer", + "ProjectLeader", + "ProjectManager", + "ProjectMember", + "RegistrationAgency", + "RegistrationAuthority", + "RelatedPerson", + "Researcher", + "ResearchGroup", + "RightsHolder", + "Sponsor", + "Supervisor", + "WorkPackageLeader", + "Other" + ] + }, + "date": { + "type": "string", + "anyOf": [ + {"format": "year"}, + {"format": "yearmonth"}, + {"format": "date"}, + {"format": "datetime"}, + {"format": "year-range"}, + {"format": "yearmonth-range"}, + {"format": "date-range"}, + {"format": "datetime-range"} + ] + }, + "dateType": { + "type": "string", + "enum": [ + "Accepted", + "Available", + "Copyrighted", + "Collected", + "Created", + "Issued", + "Submitted", + "Updated", + "Valid", + "Withdrawn", + "Other" + ] + }, + "resourceTypeGeneral": { + "type": "string", + "enum": [ + "Audiovisual", + "Collection", + "DataPaper", + "Dataset", + "Event", + "Image", + "InteractiveResource", + "Model", + "PhysicalObject", + "Service", + "Software", + "Sound", + "Text", + "Workflow", + "Other" + ] + }, + "relatedIdentifierType": { + "type": "string", + "enum": [ + "ARK", + "arXiv", + "bibcode", + "DOI", + "EAN13", + "EISSN", + "Handle", + "IGSN", + "ISBN", + "ISSN", + "ISTC", + "LISSN", + "LSID", + "PMID", + "PURL", + "UPC", + "URL", + "URN", + "w3id" + ] + }, + "relationType": { + "type": "string", + "enum": [ + "IsCitedBy", + "Cites", + "IsSupplementTo", + "IsSupplementedBy", + "IsContinuedBy", + "Continues", + "IsDescribedBy", + "Describes", + "HasMetadata", + "IsMetadataFor", + "HasVersion", + "IsVersionOf", + "IsNewVersionOf", + "IsPreviousVersionOf", + "IsPartOf", + "HasPart", + "IsReferencedBy", + "References", + "IsDocumentedBy", + "Documents", + "IsCompiledBy", + "Compiles", + "IsVariantFormOf", + "IsOriginalFormOf", + "IsIdenticalTo", + "IsReviewedBy", + "Reviews", + "IsDerivedFrom", + "IsSourceOf", + "IsRequiredBy", + "Requires", + "IsObsoletedBy", + "Obsoletes" + ] + }, + "descriptionType": { + "type": "string", + "enum": [ + "Abstract", + "Methods", + "SeriesInformation", + "TableOfContents", + "TechnicalInfo", + "Other" + ] + }, + "geoLocationPoint": { + "type": "object", + "properties": { + "pointLongitude": {"$ref": "#/definitions/longitude"}, + "pointLatitude": {"$ref": "#/definitions/latitude"} + }, + "required": ["pointLongitude", "pointLatitude"] + }, + "longitude": { + "type": "number", + "minimum": -180, + "maximum": 180 + }, + "latitude": { + "type": "number", + "minimum": -90, + "maximum": 90 + }, + "funderIdentifierType": { + "type": "string", + "enum": [ + "ISNI", + "GRID", + "Crossref Funder ID", + "ROR", + "Other" + ] + } + }, + + "type": "object", + + "properties": { + "types": { + "type": "object", + "properties": { + "resourceType": {"type": "string"}, + "resourceTypeGeneral": {"$ref": "#/definitions/resourceTypeGeneral"} + }, + "required": ["resourceType", "resourceTypeGeneral"] + }, + "identifiers": { + "type": "array", + "items":{ + "type": "object", + "properties": { + "identifier": {"type": "string"}, + "identifierType": {"type": "string"} + }, + "required": ["identifier", "identifierType"] + }, + "minItems": 1, + "uniqueItems": true + }, + "creators": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": {"type": "string"}, + "nameType": {"$ref": "#/definitions/nameType"}, + "givenName": {"type": "string"}, + "familyName": {"type": "string"}, + "nameIdentifiers": {"$ref": "#/definitions/nameIdentifiers"}, + "affiliation": {"$ref": "#/definitions/affiliations"}, + "lang": {"type": "string"} + }, + "required": ["name"] + }, + "minItems": 1, + "uniqueItems": true + }, + "titles": { + "type": "array", + "items": { + "type": "object", + "properties": { + "title": {"type": "string"}, + "titleType": {"$ref": "#/definitions/titleType"}, + "lang": {"type": "string"} + }, + "required": ["title"] + }, + "minItems": 1, + "uniqueItems": true + }, + "publisher": { + "type": "string" + }, + "publicationYear": { + "type": "string", + "format": "year" + }, + "subjects": { + "type": "array", + "items": { + "type": "object", + "properties": { + "subject": {"type": "string"}, + "subjectScheme": {"type": "string"}, + "schemeUri": {"type": "string", "format": "uri"}, + "valueUri": {"type": "string", "format": "uri"}, + "lang": {"type": "string"} + }, + "required": ["subject"] + }, + "uniqueItems": true + }, + "contributors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "contributorType": {"$ref": "#/definitions/contributorType"}, + "name": {"type": "string"}, + "nameType": {"$ref": "#/definitions/nameType"}, + "givenName": {"type": "string"}, + "familyName": {"type": "string"}, + "nameIdentifiers": {"$ref": "#/definitions/nameIdentifiers"}, + "affiliation": {"$ref": "#/definitions/affiliations"}, + "lang": {"type": "string"} + }, + "required": ["contributorType", "name"] + }, + "uniqueItems": true + }, + "dates": { + "type": "array", + "items": { + "type": "object", + "properties": { + "date": {"$ref": "#/definitions/date"}, + "dateType": {"$ref": "#/definitions/dateType"}, + "dateInformation": {"type": "string"} + }, + "required": ["date", "dateType"] + }, + "uniqueItems": true + }, + "language": { + "type": "string", + "$comment": "Primary language of the resource. Allowed values are taken from IETF BCP 47, ISO 639-1 language codes." + }, + "alternateIdentifiers": { + "type": "array", + "items": { + "type": "object", + "properties": { + "alternateIdentifier": {"type": "string"}, + "alternateIdentifierType": {"type": "string"} + }, + "required": ["alternateIdentifier", "alternateIdentifierType"] + }, + "uniqueItems": true + }, + "relatedIdentifiers": { + "type": "array", + "items": { + "type": "object", + "properties": { + "relatedIdentifier": {"type": "string"}, + "relatedIdentifierType": {"$ref": "#/definitions/relatedIdentifierType"}, + "relationType": {"$ref": "#/definitions/relationType"}, + "relatedMetadataScheme": {"type": "string"}, + "schemeUri": {"type": "string", "format": "uri"}, + "schemeType": {"type": "string"}, + "resourceTypeGeneral": {"$ref": "#/definitions/resourceTypeGeneral"} + }, + "required": ["relatedIdentifier", "relatedIdentifierType", "relationType"], + "if": { + "properties": { + "relationType": {"enum": ["HasMetadata", "IsMetadataFor"]} + } + }, + "else": { + "$comment": "these properties may only be used with relation types HasMetadata/IsMetadataFor", + "properties": { + "relatedMetadataScheme": false, + "schemeUri": false, + "schemeType": false + } + } + }, + "uniqueItems": true + }, + "sizes": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "formats": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "version": { + "type": "string" + }, + "rightsList": { + "type": "array", + "items": { + "type": "object", + "properties": { + "rights": {"type": "string"}, + "rightsUri": {"type": "string", "format": "uri"}, + "rightsIdentifier": {"type": "string"}, + "rightsIdentifierScheme": {"type": "string"}, + "schemeUri": {"type": "string", "format": "uri"}, + "lang": {"type": "string"} + } + }, + "uniqueItems": true + }, + "descriptions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "description": {"type": "string"}, + "descriptionType": {"$ref": "#/definitions/descriptionType"}, + "lang": {"type": "string"} + }, + "required": ["description", "descriptionType"] + }, + "uniqueItems": true + }, + "geoLocations": { + "type": "array", + "items": { + "type": "object", + "properties": { + "geoLocationPlace": {"type": "string"}, + "geoLocationPoint": {"$ref": "#/definitions/geoLocationPoint"}, + "geoLocationBox": { + "type": "object", + "properties": { + "westBoundLongitude": {"$ref": "#/definitions/longitude"}, + "eastBoundLongitude": {"$ref": "#/definitions/longitude"}, + "southBoundLatitude": {"$ref": "#/definitions/latitude"}, + "northBoundLatitude": {"$ref": "#/definitions/latitude"} + }, + "required": ["westBoundLongitude", "eastBoundLongitude", "southBoundLatitude", "northBoundLatitude"] + }, + "geoLocationPolygons": { + "type": "array", + "items": { + "type": "object", + "properties": { + "polygonPoints": { + "type": "array", + "items": {"$ref": "#/definitions/geoLocationPoint"}, + "minItems": 4 + }, + "inPolygonPoint": {"$ref": "#/definitions/geoLocationPoint"} + }, + "required": ["polygonPoints"] + }, + "uniqueItems": true + } + } + }, + "uniqueItems": true + }, + "fundingReferences": { + "type": "array", + "items": { + "type": "object", + "properties": { + "funderName": {"type": "string"}, + "funderIdentifier": {"type": "string"}, + "funderIdentifierType": {"$ref": "#/definitions/funderIdentifierType"}, + "awardNumber": {"type": "string"}, + "awardUri": {"type": "string", "format": "uri"}, + "awardTitle": {"type": "string"} + }, + "required": ["funderName"] + }, + "uniqueItems": true + }, + "schemaVersion": { + "type": "string", + "const": "http://datacite.org/schema/kernel-4" + }, + "container": { + "type": "object", + "properties": { + "type": {"type": "string"}, + "title": {"type": "string"}, + "firstPage": {"type": "string"} + } + } + }, + + "required": [ + "identifiers", + "creators", + "titles", + "publisher", + "publicationYear", + "types", + "schemaVersion" + ] +} diff --git a/dandischema/datacite/schema/inveniosoftware-4.3-66-g24fc2ba.json b/dandischema/datacite/schema/inveniosoftware-4.3-66-g24fc2ba.json new file mode 100644 index 00000000..1dcb8b56 --- /dev/null +++ b/dandischema/datacite/schema/inveniosoftware-4.3-66-g24fc2ba.json @@ -0,0 +1,495 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "id": "datacite-v4.3.json", + "title": "DataCite v4.3", + "description": "JSON representation of the DataCite v4.3 schema.", + "additionalProperties": false, + "definitions": { + "nameType": { + "type": "string", + "enum": [ + "Organizational", + "Personal" + ] + }, + "nameIdentifiers": { + "type": "array", + "items": { + "type": "object", + "properties": { + "nameIdentifier": {"type": "string"}, + "nameIdentifierScheme": {"type": "string"}, + "schemeUri": {"type": "string", "format": "uri"} + }, + "required": ["nameIdentifier", "nameIdentifierScheme"] + }, + "uniqueItems": true + }, + "affiliation": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": {"type": "string"}, + "affiliationIdentifier": {"type": "string"}, + "affiliationIdentifierScheme": {"type": "string"}, + "schemeUri": {"type": "string", "format": "uri"} + }, + "required": ["name"] + }, + "uniqueItems": true + }, + "titleType": { + "type": "string", + "enum": [ + "AlternativeTitle", + "Subtitle", + "TranslatedTitle", + "Other" + ] + }, + "contributorType": { + "type": "string", + "enum": [ + "ContactPerson", + "DataCollector", + "DataCurator", + "DataManager", + "Distributor", + "Editor", + "HostingInstitution", + "Producer", + "ProjectLeader", + "ProjectManager", + "ProjectMember", + "RegistrationAgency", + "RegistrationAuthority", + "RelatedPerson", + "Researcher", + "ResearchGroup", + "RightsHolder", + "Sponsor", + "Supervisor", + "WorkPackageLeader", + "Other" + ] + }, + "date": { + "type": "string", + "anyOf": [ + {"format": "year"}, + {"format": "yearmonth"}, + {"format": "date"}, + {"format": "datetime"}, + {"format": "year-range"}, + {"format": "yearmonth-range"}, + {"format": "date-range"}, + {"format": "datetime-range"} + ] + }, + "dateType": { + "type": "string", + "enum": [ + "Accepted", + "Available", + "Copyrighted", + "Collected", + "Created", + "Issued", + "Submitted", + "Updated", + "Valid", + "Withdrawn", + "Other" + ] + }, + "resourceTypeGeneral": { + "type": "string", + "enum": [ + "Audiovisual", + "Collection", + "DataPaper", + "Dataset", + "Event", + "Image", + "InteractiveResource", + "Model", + "PhysicalObject", + "Service", + "Software", + "Sound", + "Text", + "Workflow", + "Other" + ] + }, + "relatedIdentifierType": { + "type": "string", + "enum": [ + "ARK", + "arXiv", + "bibcode", + "DOI", + "EAN13", + "EISSN", + "Handle", + "IGSN", + "ISBN", + "ISSN", + "ISTC", + "LISSN", + "LSID", + "PMID", + "PURL", + "UPC", + "URL", + "URN", + "w3id" + ] + }, + "relationType": { + "type": "string", + "enum": [ + "IsCitedBy", + "Cites", + "IsSupplementTo", + "IsSupplementedBy", + "IsContinuedBy", + "Continues", + "IsDescribedBy", + "Describes", + "HasMetadata", + "IsMetadataFor", + "HasVersion", + "IsVersionOf", + "IsNewVersionOf", + "IsPreviousVersionOf", + "IsPartOf", + "HasPart", + "IsReferencedBy", + "References", + "IsDocumentedBy", + "Documents", + "IsCompiledBy", + "Compiles", + "IsVariantFormOf", + "IsOriginalFormOf", + "IsIdenticalTo", + "IsReviewedBy", + "Reviews", + "IsDerivedFrom", + "IsSourceOf", + "IsRequiredBy", + "Requires", + "IsObsoletedBy", + "Obsoletes" + ] + }, + "descriptionType": { + "type": "string", + "enum": [ + "Abstract", + "Methods", + "SeriesInformation", + "TableOfContents", + "TechnicalInfo", + "Other" + ] + }, + "geoLocationPoint": { + "type": "object", + "properties": { + "pointLongitude": {"type": "string", "format": "longitude"}, + "pointLatitude": {"type": "string", "format": "latitude"} + }, + "required": ["pointLongitude", "pointLatitude"] + }, + "funderIdentifierType": { + "type": "string", + "enum": [ + "ISNI", + "GRID", + "Crossref Funder ID", + "ROR", + "Other" + ] + } + }, + + "type": "object", + + "properties": { + "types": { + "type": "object", + "properties": { + "resourceType": {"type": "string"}, + "resourceTypeGeneral": {"$ref": "#/definitions/resourceTypeGeneral"} + }, + "required": ["resourceType", "resourceTypeGeneral"] + }, + "identifiers": { + "type": "array", + "items":{ + "type": "object", + "properties": { + "identifier": {"type": "string"}, + "identifierType": {"type": "string"} + }, + "required": ["identifier", "identifierType"] + }, + "minItems": 1, + "uniqueItems": true + }, + "creators": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": {"type": "string"}, + "nameType": {"$ref": "#/definitions/nameType"}, + "givenName": {"type": "string"}, + "familyName": {"type": "string"}, + "nameIdentifiers": {"$ref": "#/definitions/nameIdentifiers"}, + "affiliation": {"$ref": "#/definitions/affiliation"}, + "lang": {"type": "string"} + }, + "required": ["name"] + }, + "minItems": 1, + "uniqueItems": true + }, + "titles": { + "type": "array", + "items": { + "type": "object", + "properties": { + "title": {"type": "string"}, + "titleType": {"$ref": "#/definitions/titleType"}, + "lang": {"type": "string"} + }, + "required": ["title"] + }, + "minItems": 1, + "uniqueItems": true + }, + "publisher": { + "type": "string" + }, + "publicationYear": { + "type": "string", + "format": "year" + }, + "subjects": { + "type": "array", + "items": { + "type": "object", + "properties": { + "subject": {"type": "string"}, + "subjectScheme": {"type": "string"}, + "schemeUri": {"type": "string", "format": "uri"}, + "valueUri": {"type": "string", "format": "uri"}, + "lang": {"type": "string"} + }, + "required": ["subject"] + }, + "uniqueItems": true + }, + "contributors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "contributorType": {"$ref": "#/definitions/contributorType"}, + "name": {"type": "string"}, + "nameType": {"$ref": "#/definitions/nameType"}, + "givenName": {"type": "string"}, + "familyName": {"type": "string"}, + "nameIdentifiers": {"$ref": "#/definitions/nameIdentifiers"}, + "affiliation": {"$ref": "#/definitions/affiliation"}, + "lang": {"type": "string"} + }, + "required": ["contributorType", "name"] + }, + "uniqueItems": true + }, + "dates": { + "type": "array", + "items": { + "type": "object", + "properties": { + "date": {"$ref": "#/definitions/date"}, + "dateType": {"$ref": "#/definitions/dateType"}, + "dateInformation": {"type": "string"} + }, + "required": ["date", "dateType"] + }, + "uniqueItems": true + }, + "language": { + "type": "string", + "$comment": "Primary language of the resource. Allowed values are taken from IETF BCP 47, ISO 639-1 language codes." + }, + "alternateIdentifiers": { + "type": "array", + "items": { + "type": "object", + "properties": { + "alternateIdentifier": {"type": "string"}, + "alternateIdentifierType": {"type": "string"} + }, + "required": ["alternateIdentifier", "alternateIdentifierType"] + }, + "uniqueItems": true + }, + "relatedIdentifiers": { + "type": "array", + "items": { + "type": "object", + "properties": { + "relatedIdentifier": {"type": "string"}, + "relatedIdentifierType": {"$ref": "#/definitions/relatedIdentifierType"}, + "relationType": {"$ref": "#/definitions/relationType"}, + "relatedMetadataScheme": {"type": "string"}, + "schemeUri": {"type": "string", "format": "uri"}, + "schemeType": {"type": "string"}, + "resourceTypeGeneral": {"$ref": "#/definitions/resourceTypeGeneral"} + }, + "required": ["relatedIdentifier", "relatedIdentifierType", "relationType"], + "if": { + "properties": { + "relationType": {"enum": ["HasMetadata", "IsMetadataFor"]} + } + }, + "else": { + "$comment": "these properties may only be used with relation types HasMetadata/IsMetadataFor", + "properties": { + "relatedMetadataScheme": false, + "schemeUri": false, + "schemeType": false + } + } + }, + "uniqueItems": true + }, + "sizes": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "formats": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "version": { + "type": "string" + }, + "rightsList": { + "type": "array", + "items": { + "type": "object", + "properties": { + "rights": {"type": "string"}, + "rightsUri": {"type": "string", "format": "uri"}, + "rightsIdentifier": {"type": "string"}, + "rightsIdentifierScheme": {"type": "string"}, + "schemeUri": {"type": "string", "format": "uri"}, + "lang": {"type": "string"} + } + }, + "uniqueItems": true + }, + "descriptions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "description": {"type": "string"}, + "descriptionType": {"$ref": "#/definitions/descriptionType"}, + "lang": {"type": "string"} + }, + "required": ["description", "descriptionType"] + }, + "uniqueItems": true + }, + "geoLocations": { + "type": "array", + "items": { + "type": "object", + "properties": { + "geoLocationPlace": {"type": "string"}, + "geoLocationPoint": {"$ref": "#/definitions/geoLocationPoint"}, + "geoLocationBox": { + "type": "object", + "properties": { + "westBoundLongitude": {"type": "string", "format": "longitude"}, + "eastBoundLongitude": {"type": "string", "format": "longitude"}, + "southBoundLatitude": {"type": "string", "format": "latitude"}, + "northBoundLatitude": {"type": "string", "format": "latitude"} + }, + "required": ["westBoundLongitude", "eastBoundLongitude", "southBoundLatitude", "northBoundLatitude"] + }, + "geoLocationPolygons": { + "type": "array", + "items": { + "type": "object", + "properties": { + "polygonPoints": { + "type": "array", + "items": {"$ref": "#/definitions/geoLocationPoint"}, + "minItems": 4 + }, + "inPolygonPoint": {"$ref": "#/definitions/geoLocationPoint"} + }, + "required": ["polygonPoints"] + }, + "uniqueItems": true + } + } + }, + "uniqueItems": true + }, + "fundingReferences": { + "type": "array", + "items": { + "type": "object", + "properties": { + "funderName": {"type": "string"}, + "funderIdentifier": {"type": "string"}, + "funderIdentifierType": {"$ref": "#/definitions/funderIdentifierType"}, + "awardNumber": {"type": "string"}, + "awardUri": {"type": "string", "format": "uri"}, + "awardTitle": {"type": "string"} + }, + "required": ["funderName"] + }, + "uniqueItems": true + }, + "schemaVersion": { + "type": "string", + "const": "http://datacite.org/schema/kernel-4" + }, + "container": { + "type": "object", + "properties": { + "type": {"type": "string"}, + "title": {"type": "string"}, + "firstPage": {"type": "string"} + } + } + }, + + "required": [ + "identifiers", + "creators", + "titles", + "publisher", + "publicationYear", + "types", + "schemaVersion" + ] +} diff --git a/dandischema/datacite/schema/inveniosoftware-4.5-81-g160250d.json b/dandischema/datacite/schema/inveniosoftware-4.5-81-g160250d.json new file mode 100644 index 00000000..e6bc65d0 --- /dev/null +++ b/dandischema/datacite/schema/inveniosoftware-4.5-81-g160250d.json @@ -0,0 +1,628 @@ +{ + "$schema": "http://json-schema.org/2019-09/schema#", + "id": "datacite-v4.5.json", + "title": "DataCite v4.5", + "description": "JSON representation of the DataCite v4.5 schema.", + "additionalProperties": false, + "definitions": { + "nameType": { + "type": "string", + "enum": [ + "Organizational", + "Personal" + ] + }, + "nameIdentifiers": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "nameIdentifier": {"type": "string"}, + "nameIdentifierScheme": {"type": "string"}, + "schemeUri": {"type": "string", "format": "uri"} + }, + "required": ["nameIdentifier", "nameIdentifierScheme"] + }, + "uniqueItems": true + }, + "affiliation": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "name": {"type": "string"}, + "affiliationIdentifier": {"type": "string"}, + "affiliationIdentifierScheme": {"type": "string"}, + "schemeUri": {"type": "string", "format": "uri"} + }, + "required": ["name"] + }, + "uniqueItems": true + }, + "person": { + "type": "object", + "properties": { + "name": {"type": "string"}, + "nameType": {"$ref": "#/definitions/nameType"}, + "givenName": {"type": "string"}, + "familyName": {"type": "string"}, + "nameIdentifiers": {"$ref": "#/definitions/nameIdentifiers"}, + "affiliation": {"$ref": "#/definitions/affiliation"}, + "lang": {"type": "string"} + }, + "required": ["name"] + }, + "creator": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/person" }], + "unevaluatedProperties": false + }, + "contributor": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/person" }], + "unevaluatedProperties": false, + "properties": { + "contributorType": {"$ref": "#/definitions/contributorType"} + }, + "required": ["name", "contributorType"] + }, + "contributorType": { + "type": "string", + "enum": [ + "ContactPerson", + "DataCollector", + "DataCurator", + "DataManager", + "Distributor", + "Editor", + "HostingInstitution", + "Producer", + "ProjectLeader", + "ProjectManager", + "ProjectMember", + "RegistrationAgency", + "RegistrationAuthority", + "RelatedPerson", + "Researcher", + "ResearchGroup", + "RightsHolder", + "Sponsor", + "Supervisor", + "WorkPackageLeader", + "Other" + ] + }, + "titleType": { + "type": "string", + "enum": [ + "AlternativeTitle", + "Subtitle", + "TranslatedTitle", + "Other" + ] + }, + "longitude": { + "type": "number", + "maximum": 180, + "minimum": -180 + }, + "latitude": { + "type": "number", + "maximum": 90, + "minimum": -90 + }, + "date": { + "type": "string", + "anyOf": [ + {"format": "year"}, + {"format": "yearmonth"}, + {"format": "date"}, + {"format": "datetime"}, + {"format": "year-range"}, + {"format": "yearmonth-range"}, + {"format": "date-range"}, + {"format": "datetime-range"} + ] + }, + "dateType": { + "type": "string", + "enum": [ + "Accepted", + "Available", + "Copyrighted", + "Collected", + "Created", + "Issued", + "Submitted", + "Updated", + "Valid", + "Withdrawn", + "Other" + ] + }, + "resourceTypeGeneral": { + "type": "string", + "enum": [ + "Audiovisual", + "Book", + "BookChapter", + "Collection", + "ComputationalNotebook", + "ConferencePaper", + "ConferenceProceeding", + "DataPaper", + "Dataset", + "Dissertation", + "Event", + "Image", + "Instrument", + "InteractiveResource", + "Journal", + "JournalArticle", + "Model", + "OutputManagementPlan", + "PeerReview", + "PhysicalObject", + "Preprint", + "Report", + "Service", + "Software", + "Sound", + "Standard", + "StudyRegistration", + "Text", + "Workflow", + "Other" + ] + }, + "relatedIdentifierType": { + "type": "string", + "enum": [ + "ARK", + "arXiv", + "bibcode", + "DOI", + "EAN13", + "EISSN", + "Handle", + "IGSN", + "ISBN", + "ISSN", + "ISTC", + "LISSN", + "LSID", + "PMID", + "PURL", + "UPC", + "URL", + "URN", + "w3id" + ] + }, + "relationType": { + "type": "string", + "enum": [ + "IsCitedBy", + "Cites", + "IsCollectedBy", + "Collects", + "IsSupplementTo", + "IsSupplementedBy", + "IsContinuedBy", + "Continues", + "IsDescribedBy", + "Describes", + "HasMetadata", + "IsMetadataFor", + "HasVersion", + "IsVersionOf", + "IsNewVersionOf", + "IsPartOf", + "IsPreviousVersionOf", + "IsPublishedIn", + "HasPart", + "IsReferencedBy", + "References", + "IsDocumentedBy", + "Documents", + "IsCompiledBy", + "Compiles", + "IsVariantFormOf", + "IsOriginalFormOf", + "IsIdenticalTo", + "IsReviewedBy", + "Reviews", + "IsDerivedFrom", + "IsSourceOf", + "IsRequiredBy", + "Requires", + "IsObsoletedBy", + "Obsoletes" + ] + }, + "relatedObject": { + "type": "object", + "properties": { + "relationType": {"$ref": "#/definitions/relationType"}, + "relatedMetadataScheme": {"type": "string"}, + "schemeUri": {"type": "string", "format": "uri"}, + "schemeType": {"type": "string"}, + "resourceTypeGeneral": {"$ref": "#/definitions/resourceTypeGeneral"} + }, + "required": ["relationType"] + }, + "relatedObjectIf": { + "properties": { + "relationType": {"enum": ["HasMetadata", "IsMetadataFor"]} + } + }, + "relatedObjectElse": { + "$comment": "these properties may only be used with relation types HasMetadata/IsMetadataFor", + "properties": { + "relatedMetadataScheme": false, + "schemeUri": false, + "schemeType": false + } + }, + "descriptionType": { + "type": "string", + "enum": [ + "Abstract", + "Methods", + "SeriesInformation", + "TableOfContents", + "TechnicalInfo", + "Other" + ] + }, + "geoLocationPoint": { + "type": "object", + "additionalProperties": false, + "properties": { + "pointLongitude": {"$ref": "#/definitions/longitude"}, + "pointLatitude": {"$ref": "#/definitions/latitude"} + }, + "required": ["pointLongitude", "pointLatitude"] + }, + "funderIdentifierType": { + "type": "string", + "enum": [ + "ISNI", + "GRID", + "Crossref Funder ID", + "ROR", + "Other" + ] + }, + "publicationYear": { + "type": "string", + "pattern": "^[0-9]{4}$" + } + }, + "type": "object", + "properties": { + "doi": {"type": "string", "pattern" : "^10[.][0-9]{4,9}[/][^\\s]+$"}, + "prefix":{"type": "string", "pattern": "^10[.][0-9]{4,9}$"}, + "suffix":{"type": "string", "pattern": "^[^\\s]+$"}, + "event" : { + "type": "string", + "enum": [ + "hide", + "register", + "publish" + ] + }, + "url": {"type": "string", "format": "uri"}, + "types": { + "type": "object", + "additionalProperties": false, + "properties": { + "resourceType": {"type": "string"}, + "resourceTypeGeneral": {"$ref": "#/definitions/resourceTypeGeneral"} + }, + "required": ["resourceTypeGeneral"] + }, + "creators": { + "type": "array", + "items": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/creator" }], + "required": ["name"] + }, + "minItems": 1 + }, + "titles": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "title": {"type": "string"}, + "titleType": {"$ref": "#/definitions/titleType"}, + "lang": {"type": "string"} + }, + "required": ["title"] + }, + "minItems": 1, + "uniqueItems": true + }, + "publisher": { + "type": "object", + "additionalProperties": false, + "properties": { + "name": {"type":"string"}, + "publisherIdentifier": {"type":"string"}, + "publisherIdentifierScheme": {"type":"string"}, + "schemeUri": {"type":"string", "format": "uri"}, + "lang": {"type":"string"} + }, + "required": ["name"] + }, + "publicationYear": {"$ref": "#/definitions/publicationYear"}, + "subjects": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "subject": {"type": "string"}, + "subjectScheme": {"type": "string"}, + "schemeUri": {"type": "string", "format": "uri"}, + "valueUri": {"type": "string", "format": "uri"}, + "classificationCode": {"type": "string"}, + "lang": {"type": "string"} + }, + "required": ["subject"] + }, + "uniqueItems": true + }, + "contributors": { + "type": "array", + "items": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/contributor" }], + "required": ["contributorType", "name"] + } + }, + "dates": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "date": {"$ref": "#/definitions/date"}, + "dateType": {"$ref": "#/definitions/dateType"}, + "dateInformation": {"type": "string"} + }, + "required": ["date", "dateType"] + }, + "uniqueItems": true + }, + "language": { + "type": "string", + "$comment": "Primary language of the resource. Allowed values are taken from IETF BCP 47, ISO 639-1 language codes." + }, + "alternateIdentifiers": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "alternateIdentifier": {"type": "string"}, + "alternateIdentifierType": {"type": "string"} + }, + "required": ["alternateIdentifier", "alternateIdentifierType"] + }, + "uniqueItems": true + }, + "relatedIdentifiers": { + "type": "array", + "items": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/relatedObject"}], + "unevaluatedProperties": false, + "properties": { + "relatedIdentifier": {"type": "string"}, + "relatedIdentifierType": {"$ref": "#/definitions/relatedIdentifierType"} + }, + "required": ["relatedIdentifier", "relatedIdentifierType", "relationType"], + "if": {"$ref": "#/definitions/relatedObjectIf"}, + "else": {"$ref": "#/definitions/relatedObjectElse"} + } + }, + "relatedItems": { + "type": "array", + "items": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/relatedObject"}], + "unevaluatedProperties": false, + "properties": { + "relatedItemIdentifier": { + "type": "object", + "additionalProperties": false, + "properties": { + "relatedItemIdentifier": {"type": "string"}, + "relatedItemIdentifierType": {"$ref": "#/definitions/relatedIdentifierType"} + }, + "required": ["relatedItemIdentifier", "relatedItemIdentifierType"] + }, + "relatedItemType": {"$ref": "#/definitions/resourceTypeGeneral"}, + "creators": { + "type": "array", + "items": { + "type": "object", + "unevaluatedProperties": false, + "allOf": [{ "$ref": "#/definitions/creator" }], + "required": ["name"] + } + }, + "contributors": { + "type": "array", + "items": { + "type": "object", + "unevaluatedProperties": false, + "allOf": [{ "$ref": "#/definitions/contributor" }], + "required": ["contributorType", "name"] + } + }, + "titles": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "title": {"type": "string"}, + "titleType": {"$ref": "#/definitions/titleType"}, + "lang": {"type": "string"} + }, + "required": ["title"] + }, + "minItems": 1, + "uniqueItems": true + }, + "publicationYear": {"$ref": "#/definitions/publicationYear"}, + "volume": {"type": "string"}, + "issue": {"type": "string"}, + "firstPage": {"type": "string"}, + "lastPage": {"type": "string"}, + "edition": {"type": "string"}, + "publisher": {"type": "string"}, + "number": {"type":"string"}, + "numberType": { + "type": "string", + "enum": [ + "Article", + "Chapter", + "Report", + "Other" + ] + } + }, + "required": ["titles", "relatedItemType", "relationType"], + "if": {"$ref": "#/definitions/relatedObjectIf"}, + "else": {"$ref": "#/definitions/relatedObjectElse"} + }, + "uniqueItems": true + }, + "sizes": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "formats": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "version": { + "type": "string" + }, + "rightsList": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "rights": {"type": "string"}, + "rightsUri": {"type": "string", "format": "uri"}, + "rightsIdentifier": {"type": "string"}, + "rightsIdentifierScheme": {"type": "string"}, + "schemeUri": {"type": "string", "format": "uri"}, + "lang": {"type": "string"} + } + }, + "uniqueItems": true + }, + "descriptions": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "description": {"type": "string"}, + "descriptionType": {"$ref": "#/definitions/descriptionType"}, + "lang": {"type": "string"} + }, + "required": ["description", "descriptionType"] + }, + "uniqueItems": true + }, + "geoLocations": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "geoLocationPlace": {"type": "string"}, + "geoLocationPoint": {"$ref": "#/definitions/geoLocationPoint"}, + "geoLocationBox": { + "type": "object", + "additionalProperties": false, + "properties": { + "westBoundLongitude": {"$ref": "#/definitions/longitude"}, + "eastBoundLongitude": {"$ref": "#/definitions/longitude"}, + "southBoundLatitude": {"$ref": "#/definitions/latitude"}, + "northBoundLatitude": {"$ref": "#/definitions/latitude"} + }, + "required": ["westBoundLongitude", "eastBoundLongitude", "southBoundLatitude", "northBoundLatitude"] + }, + "geoLocationPolygon": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "polygonPoint": {"$ref": "#/definitions/geoLocationPoint"}, + "inPolygonPoint": {"$ref": "#/definitions/geoLocationPoint"} + } + } + } + } + }, + "uniqueItems": true + }, + "fundingReferences": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "funderName": {"type": "string"}, + "funderIdentifier": {"type": "string"}, + "funderIdentifierType": {"$ref": "#/definitions/funderIdentifierType"}, + "awardNumber": {"type": "string"}, + "awardUri": {"type": "string", "format": "uri"}, + "awardTitle": {"type": "string"} + }, + "required": ["funderName"] + }, + "uniqueItems": true + }, + "schemaVersion": { + "type": "string", + "const": "http://datacite.org/schema/kernel-4" + }, + "container": { + "type": "object", + "properties": { + "type": {"type": "string"}, + "title": {"type": "string"}, + "firstPage": {"type": "string"} + } + } + }, + "required": [ + "creators", + "titles", + "publisher", + "publicationYear", + "types", + "schemaVersion" + ] +} From 115bee0defa84ce19f81779a0e8988a7e1ff1c7e Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 4 Nov 2024 10:55:21 -0500 Subject: [PATCH 5/6] Move datacite tests to reside near the datacite code --- dandischema/datacite/tests/__init__.py | 0 dandischema/{ => datacite}/tests/test_datacite.py | 12 ++++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 dandischema/datacite/tests/__init__.py rename dandischema/{ => datacite}/tests/test_datacite.py (98%) diff --git a/dandischema/datacite/tests/__init__.py b/dandischema/datacite/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/dandischema/tests/test_datacite.py b/dandischema/datacite/tests/test_datacite.py similarity index 98% rename from dandischema/tests/test_datacite.py rename to dandischema/datacite/tests/test_datacite.py index 8ed971e3..efdfdd8d 100644 --- a/dandischema/tests/test_datacite.py +++ b/dandischema/datacite/tests/test_datacite.py @@ -9,15 +9,17 @@ import pytest import requests -from .utils import skipif_no_network -from ..datacite import _get_datacite_schema, to_datacite -from ..models import ( +from dandischema.models import ( LicenseType, PublishedDandiset, RelationType, ResourceType, RoleType, ) +import dandischema.tests +from dandischema.tests.utils import skipif_no_network + +from .. import _get_datacite_schema, to_datacite def datacite_post(datacite: dict, doi: str) -> None: @@ -142,7 +144,9 @@ def test_datacite(dandi_id: str, schema: Any) -> None: # reading metadata taken from exemplary dandisets and saved in json files with ( - Path(__file__).with_name("data") / "metadata" / f"meta_{dandi_id}.json" + Path(dandischema.tests.__file__).with_name("data") + / "metadata" + / f"meta_{dandi_id}.json" ).open() as f: meta_js = json.load(f) From a9c909fd55b33c0ad81b470b79b7cf75d17c2439 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 4 Nov 2024 11:01:51 -0500 Subject: [PATCH 6/6] BF: move reused _basic_publishmeta into dandischema/datacite/__init__.py + fix typing issue --- dandischema/datacite/__init__.py | 2 +- dandischema/datacite/tests/test_datacite.py | 34 +-------------------- dandischema/tests/test_models.py | 2 +- dandischema/tests/utils.py | 33 ++++++++++++++++++++ 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/dandischema/datacite/__init__.py b/dandischema/datacite/__init__.py index 57423823..8a8040d7 100644 --- a/dandischema/datacite/__init__.py +++ b/dandischema/datacite/__init__.py @@ -252,7 +252,7 @@ def to_datacite( @lru_cache() -def _get_datacite_schema(version_id: str = "datacite-4.3-17-gaa5db56") -> dict: +def _get_datacite_schema(version_id: str = "datacite-4.3-17-gaa5db56") -> Any: """Load datacite schema based on the version id provided.""" schema_folder = Path(__file__).parent / "schema" return json.loads((schema_folder / f"{version_id}.json").read_text()) diff --git a/dandischema/datacite/tests/test_datacite.py b/dandischema/datacite/tests/test_datacite.py index efdfdd8d..f1d129ae 100644 --- a/dandischema/datacite/tests/test_datacite.py +++ b/dandischema/datacite/tests/test_datacite.py @@ -1,4 +1,3 @@ -from datetime import datetime import json import os from pathlib import Path @@ -17,7 +16,7 @@ RoleType, ) import dandischema.tests -from dandischema.tests.utils import skipif_no_network +from dandischema.tests.utils import _basic_publishmeta, skipif_no_network from .. import _get_datacite_schema, to_datacite @@ -103,37 +102,6 @@ def metadata_basic() -> Dict[str, Any]: return meta_dict -def _basic_publishmeta( - dandi_id: str, version: str = "0.0.0", prefix: str = "10.80507" -) -> Dict[str, Any]: - """Return extra metadata required by PublishedDandiset - - Returned fields are additional to fields required by Dandiset - """ - publish_meta = { - "datePublished": str(datetime.now().year), - "publishedBy": { - "id": "urn:uuid:08fffc59-9f1b-44d6-8e02-6729d266d1b6", - "name": "DANDI publish", - "startDate": "2021-05-18T19:58:39.310338-04:00", - "endDate": "2021-05-18T19:58:39.310361-04:00", - "wasAssociatedWith": [ - { - "id": "urn:uuid:9267d2e1-4a37-463b-9b10-dad3c66d8eaa", - "identifier": "RRID:SCR_017571", - "name": "DANDI API", - "version": "0.1.0", - "schemaKey": "Software", - } - ], - "schemaKey": "PublishActivity", - }, - "version": version, - "doi": f"{prefix}/dandi.{dandi_id}/{version}", - } - return publish_meta - - @skipif_no_network @pytest.mark.skipif( not os.getenv("DATACITE_DEV_PASSWORD"), reason="no datacite password available" diff --git a/dandischema/tests/test_models.py b/dandischema/tests/test_models.py index 801dab2a..9b0e5101 100644 --- a/dandischema/tests/test_models.py +++ b/dandischema/tests/test_models.py @@ -7,7 +7,7 @@ from pydantic import Field, ValidationError import pytest -from .test_datacite import _basic_publishmeta +from .utils import _basic_publishmeta from .. import models from ..models import ( DANDI_INSTANCE_URL_PATTERN, diff --git a/dandischema/tests/utils.py b/dandischema/tests/utils.py index e01da850..5e76d5da 100644 --- a/dandischema/tests/utils.py +++ b/dandischema/tests/utils.py @@ -1,7 +1,40 @@ +from datetime import datetime import os +from typing import Any, Dict import pytest skipif_no_network = pytest.mark.skipif( bool(os.environ.get("DANDI_TESTS_NONETWORK")), reason="no network settings" ) + + +def _basic_publishmeta( + dandi_id: str, version: str = "0.0.0", prefix: str = "10.80507" +) -> Dict[str, Any]: + """Return extra metadata required by PublishedDandiset + + Returned fields are additional to fields required by Dandiset + """ + publish_meta = { + "datePublished": str(datetime.now().year), + "publishedBy": { + "id": "urn:uuid:08fffc59-9f1b-44d6-8e02-6729d266d1b6", + "name": "DANDI publish", + "startDate": "2021-05-18T19:58:39.310338-04:00", + "endDate": "2021-05-18T19:58:39.310361-04:00", + "wasAssociatedWith": [ + { + "id": "urn:uuid:9267d2e1-4a37-463b-9b10-dad3c66d8eaa", + "identifier": "RRID:SCR_017571", + "name": "DANDI API", + "version": "0.1.0", + "schemaKey": "Software", + } + ], + "schemaKey": "PublishActivity", + }, + "version": version, + "doi": f"{prefix}/dandi.{dandi_id}/{version}", + } + return publish_meta