[Bug 42753] New: item-api-client.js: items.get() should accept headers parameter instead of hardcoding x-koha-embed
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42753 Bug ID: 42753 Summary: item-api-client.js: items.get() should accept headers parameter instead of hardcoding x-koha-embed Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: REST API Assignee: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com QA Contact: testopia@bugs.koha-community.org CC: tomascohen@gmail.com ItemAPIClient.items.get(id) hardcodes x-koha-embed: '+strings' in the request headers. This should be passed through from the caller (like getAll already does) so different consumers can request different embeds. Current: get: id => this.httpClient.get({ endpoint: 'items/' + id, headers: { 'x-koha-embed': '+strings' }, }), Should be: get: (id, params = {}) => this.httpClient.get({ endpoint: 'items/' + id, ...params, }), Callers that need +strings would pass it explicitly: APIClient.item.items.get(id, { headers: { 'x-koha-embed': '+strings' } }) This follows the same pass-through pattern used for bundled_items.add(). -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42753 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Patch complexity|--- |Trivial patch Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42753 --- Comment #1 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 199836 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=199836&action=edit Bug 42753: Add embed parameter support to HttpClient HttpClient now recognizes an 'embed' parameter in request options. When provided (as an array or string), it is automatically translated into the 'x-koha-embed' HTTP header. This centralizes embed handling so individual API clients don't need to build headers manually. Callers express intent declaratively: APIClient.item.items.get(id, { embed: ['+strings', 'biblio'] }) The embed header is built by _buildHeaders() which is called by all HTTP methods (get, getAll, post, put, patch, delete). Explicit headers passed via params.headers take precedence over embed-generated ones. Also updates ItemAPIClient.items.get() to accept params (including embed) instead of hardcoding x-koha-embed: '+strings'. Callers that need +strings now pass it explicitly. Test plan: 1. Apply patch 2. Verify preservation module still works (uses item_types via getAll) 3. Verify ILL supplying resource still fetches items 4. Sign off :-D Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42753 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@gmail.com, | |matt.blenkinsop@openfifth.c | |o.uk, | |pedro.amorim@openfifth.co.u | |k -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42753 --- Comment #2 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- I tracked the places that used `APIClient.item.items.get` and found none using `_strings`. If I missed some, please let me know! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42753 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |RESOLVED Resolution|--- |DUPLICATE --- Comment #3 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- On iterating on this (didn't like 100% what I come up with) I ended up writing what I proposed on bug 36369, which I forgot about, but what I wrote sounded familiar :-D Closing this one, and submitting there. *** This bug has been marked as a duplicate of bug 36369 *** -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org