Closed (fixed)
Project:
JSON:API Response Alter
Version:
1.0.0
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
15 Feb 2023 at 14:00 UTC
Updated:
26 Oct 2023 at 11:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
Abdalhamid commentedComment #3
Abdalhamid commentedfixing patch name
Comment #4
Abdalhamid commentedComment #5
ruuds commentedLooking at this, i was thinking... Wouldn't it be enough to just check if \Drupal\jsonapi\Routing::isJsonApiRequest(...) is TRUE?
Jsonapi_menu_items also implements the requirements for isJsonApiRequest to return TRUE. And this would also open up support for other related JSON:API requests.
Comment #6
jrbWe'd like to use this module with the JSON:API Search API module, but are seeing the same problem.
That does not look like it would work. That
Routes::isJsonApiRequest()method basically checks this:So, it's looking to see if the "_controller" defaults setting starts with "jsonapi.entity_resource". That's not the case for the JSON:API Menu Items module (or the JSON:API Search API).
Here's what the the route defaults look like for core and the other two modules.
Core - Taxonomy terms for a vocabulary
JSON:API Search API - jsonapi_search_api
JSON:API Menu Items - jsonapi_menu_items
In each case,
_is_jsonapiis set to TRUE, so it looks like that would be the best thing to check. I've attached a patch that adds a check for this to the existing conditional inResponseSubscriber::onResponse(), but it may be possible to just replace the 3 checks with this single check instead:That would work for core and these 2 modules.
I've updated the title and description for this issue to include the JSON:API Search API module (and potentially other modules).
Comment #8
ruuds commentedThanks, that would do the trick indeed! Creating a new release shortly.