Skip to content

Commit

Permalink
records-api: add Data Package serializer
Browse files Browse the repository at this point in the history
* Exposes the Data Package serializer under a JSON-LD serialization with
  the appropriate profile parameter.
  • Loading branch information
slint committed Dec 9, 2024
1 parent 5090c80 commit 7b6915f
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit 7b6915f

Please sign in to comment.