Skip to content

Commit

Permalink
feat: files serializer use marc21 accept header
Browse files Browse the repository at this point in the history
  • Loading branch information
philippgualdi committed Sep 26, 2024
1 parent 00de64f commit 8787fa3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions invenio_records_marc21/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
"Content-Type": "application/json",
"Accept": "application/vnd.inveniomarc21.v1+marcxml",
},
"octet-stream": {"Content-Type": "application/octet-stream"},
}
"""The api headers for the RDM deposit app."""

Expand Down
13 changes: 10 additions & 3 deletions invenio_records_marc21/resources/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from .serializers import Marc21JSONSerializer, Marc21XMLSerializer
from .serializers.ui import Marc21UIJSONSerializer, Marc21UIXMLSerializer

record_serializer = {
record_serializers = {
"application/json": ResponseHandler(Marc21JSONSerializer()),
"application/marcxml": ResponseHandler(Marc21XMLSerializer()),
"application/vnd.inveniomarc21.v1+json": ResponseHandler(Marc21UIJSONSerializer()),
Expand Down Expand Up @@ -51,7 +51,7 @@ class Marc21RecordResourceConfig(RecordResourceConfig):

default_accept_mimetype = "application/json"

response_handlers = record_serializer
response_handlers = record_serializers

request_view_args = {
"pid_value": ma.fields.Str(),
Expand Down Expand Up @@ -92,6 +92,12 @@ class Marc21DraftFilesResourceConfig(FileResourceConfig):

blueprint_name = "marc21_draft_files"
url_prefix = f"{url_prefix}/<pid_value>/draft"
response_handlers = { # noqa: RUF012
"application/vnd.inveniomarc21.v1+marcxml": FileResourceConfig.response_handlers[
"application/json"
],
**FileResourceConfig.response_handlers,
}


class Marc21ParentRecordLinksResourceConfig(RecordResourceConfig):
Expand All @@ -111,4 +117,5 @@ class Marc21ParentRecordLinksResourceConfig(RecordResourceConfig):

request_view_args = {"pid_value": ma.fields.Str(), "link_id": ma.fields.Str()}

response_handlers = {"application/json": ResponseHandler(Marc21JSONSerializer())}
# response_handlers = {"application/json": ResponseHandler(Marc21JSONSerializer())}
response_handlers = record_serializers

0 comments on commit 8787fa3

Please sign in to comment.