Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

records-api: add Data Package serializer #1905

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion invenio_rdm_records/resources/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
CSVRecordSerializer,
DataCite43JSONSerializer,
DataCite43XMLSerializer,
DataPackageSerializer,
DCATSerializer,
DublinCoreXMLSerializer,
FAIRSignpostingProfileLvl2Serializer,
Expand Down Expand Up @@ -84,6 +85,10 @@ def _bibliography_headers(obj_or_list, code, many=False):
return _etag_headers


# Schema.org profiles
DATAPACKAGE_PROFILE = "https://datapackage.org/profiles/2.0/datapackage.json"
ROCRATE_PROFILE = "https://w3id.org/ro/crate/1.1"

record_serializers = {
"application/json": ResponseHandler(JSONSerializer(), headers=etag_headers),
"application/ld+json": ResponseHandler(SchemaorgJSONLDSerializer()),
Expand Down Expand Up @@ -123,6 +128,9 @@ def _bibliography_headers(obj_or_list, code, many=False):
"application/vnd.datacite.datacite+xml": ResponseHandler(
DataCite43XMLSerializer(), headers=etag_headers
),
f'application/ld+json;profile="{DATAPACKAGE_PROFILE}"': ResponseHandler(
DataPackageSerializer(), headers=etag_headers
),
"application/x-dc+xml": ResponseHandler(
DublinCoreXMLSerializer(), headers=etag_headers
),
Expand Down Expand Up @@ -251,7 +259,7 @@ class RDMRecordResourceConfig(RecordResourceConfig, ConfiguratorMixin):

request_body_parsers = {
"application/json": RequestBodyParser(JSONDeserializer()),
'application/ld+json;profile="https://w3id.org/ro/crate/1.1"': RequestBodyParser(
f'application/ld+json;profile="{ROCRATE_PROFILE}"': RequestBodyParser(
ROCrateJSONDeserializer()
),
}
Expand Down
8 changes: 8 additions & 0 deletions tests/resources/serializers/test_signposting_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def test_signposting_serializer_full(running_app, full_record_to_dict):
"href": "https://127.0.0.1:5000/api/records/12345-abcde",
"type": "application/ld+json",
},
{
"href": "https://127.0.0.1:5000/api/records/12345-abcde",
"type": 'application/ld+json;profile="https://datapackage.org/profiles/2.0/datapackage.json"',
},
{
"href": "https://127.0.0.1:5000/api/records/12345-abcde",
"type": "application/linkset+json",
Expand Down Expand Up @@ -146,6 +150,10 @@ def test_signposting_serializer_minimal(running_app, minimal_record_to_dict):
"href": "https://127.0.0.1:5000/api/records/67890-fghij",
"type": "application/ld+json",
},
{
"href": "https://127.0.0.1:5000/api/records/67890-fghij",
"type": 'application/ld+json;profile="https://datapackage.org/profiles/2.0/datapackage.json"',
},
{
"href": "https://127.0.0.1:5000/api/records/67890-fghij",
"type": "application/linkset+json",
Expand Down
Loading