Skip to content

Commit

Permalink
http headers: use and adjust vnd.inveniordm.v1+json http accept header
Browse files Browse the repository at this point in the history
  • Loading branch information
anikachurilova authored and kpsherva committed Aug 9, 2024
1 parent 92fb586 commit 9f0490c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions invenio_vocabularies/contrib/affiliations/affiliations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

"""Vocabulary affiliations."""

from flask_resources import JSONSerializer, ResponseHandler
from invenio_db import db
from invenio_records.dumpers import SearchDumper
from invenio_records.dumpers.indexedat import IndexedAtDumperExt
from invenio_records_resources.factories.factory import RecordTypeFactory
from invenio_records_resources.records.systemfields import ModelPIDField
from invenio_records_resources.resources.records.headers import etag_headers

from ...services.permissions import PermissionPolicy
from .config import AffiliationsSearchOptions, service_components
Expand Down Expand Up @@ -46,4 +48,12 @@
permission_policy_cls=PermissionPolicy,
# Resource layer
endpoint_route="/affiliations",
resource_cls_attrs={
"response_handlers": {
"application/json": ResponseHandler(JSONSerializer(), headers=etag_headers),
"application/vnd.inveniordm.v1+json": ResponseHandler(
JSONSerializer(), headers=etag_headers
),
}
},
)
10 changes: 10 additions & 0 deletions invenio_vocabularies/contrib/names/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

"""Vocabulary names."""

from flask_resources import JSONSerializer, ResponseHandler
from invenio_db import db
from invenio_records.dumpers import SearchDumper
from invenio_records.dumpers.indexedat import IndexedAtDumperExt
Expand All @@ -18,6 +19,7 @@
ModelPIDField,
PIDListRelation,
)
from invenio_records_resources.resources.records.headers import etag_headers

from ...services.permissions import PermissionPolicy
from ..affiliations.api import Affiliation
Expand Down Expand Up @@ -63,4 +65,12 @@
permission_policy_cls=PermissionPolicy,
# Resource layer
endpoint_route="/names",
resource_cls_attrs={
"response_handlers": {
"application/json": ResponseHandler(JSONSerializer(), headers=etag_headers),
"application/vnd.inveniordm.v1+json": ResponseHandler(
JSONSerializer(), headers=etag_headers
),
}
},
)
10 changes: 10 additions & 0 deletions invenio_vocabularies/contrib/subjects/subjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

"""Vocabulary subjects."""

from flask_resources import JSONSerializer, ResponseHandler
from invenio_records.dumpers import SearchDumper
from invenio_records.dumpers.indexedat import IndexedAtDumperExt
from invenio_records_resources.factories.factory import RecordTypeFactory
from invenio_records_resources.resources.records.headers import etag_headers

from ...records.pidprovider import PIDProviderFactory
from ...records.systemfields import BaseVocabularyPIDFieldContext
Expand Down Expand Up @@ -42,4 +44,12 @@
permission_policy_cls=PermissionPolicy,
# Resource layer
endpoint_route="/subjects",
resource_cls_attrs={
"response_handlers": {
"application/json": ResponseHandler(JSONSerializer(), headers=etag_headers),
"application/vnd.inveniordm.v1+json": ResponseHandler(
JSONSerializer(), headers=etag_headers
),
}
},
)

0 comments on commit 9f0490c

Please sign in to comment.