[Bug 43795] New: Add REST API routes for MARC modification templates (read-only)
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 Bug ID: 43795 Summary: Add REST API routes for MARC modification templates (read-only) 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: martin.renvoize@openfifth.co.uk QA Contact: tomascohen@gmail.com CC: tomascohen@gmail.com Target Milestone: --- Koha has no REST API for MARC modification templates (the marc_modification_templates and marc_modification_template_actions tables, managed in Tools > MARC modification templates and applied by C4::MarcModificationTemplates). Anything that needs to offer or display a template has to load the list server-side in a Perl script and embed it in the page. A concrete example: bug 30800 (a management page for MARC import staging profiles) needs a template dropdown in a Vue form, and the profiles REST resource (/import_batch_profiles) only returns the bare template_id. Proposal Add a read-only REST resource: - GET /marc_modification_templates (list, with the usual query, pagination and ordering support) - GET /marc_modification_templates/{marc_modification_template_id} Fields to expose: marc_modification_template_id (template_id) and name. The actions belonging to a template could be exposed later through ?_embed, but are out of scope for this bug. Implementation notes - There are DBIC result classes (Koha::Schema::Result::MarcModificationTemplate and ...Action) but no Koha::Object wrappers yet; add Koha::MarcModificationTemplate and Koha::MarcModificationTemplates. - Add the swagger definition and paths, and a Koha::REST::V1 controller. - Add unit tests for the object classes and REST tests under t/db_dependent/api/v1/. Open questions 1. Permissions. Managing templates uses the tools: marc_modification_templates permission, but a cataloguer staging records (tools: stage_marc_import) or doing batch modifications must be able to choose a template. Reading should probably be allowed with any of these; how best to express that in x-koha-authorization? 2. Write operations (add/edit/delete) and the template actions are deliberately left to later bugs. -- 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=43795 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |30800 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30800 [Bug 30800] Ability to view, modify, and delete profiles for staging MARC records for import -- 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=43795 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk -- 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=43795 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 207966 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207966&action=edit Bug 43795: Add Koha::MarcModificationTemplate(s) object classes This patch adds Koha::MarcModificationTemplate and Koha::MarcModificationTemplates object classes on top of the marc_modification_templates table, along with unit tests. The next patch adds REST API routes built on these classes. Test plan: 1. Apply both patches of this bug 2. yarn build; restart_all 3. prove t/db_dependent/Koha/MarcModificationTemplates.t \ t/db_dependent/api/v1/marc_modification_templates.t 4. Both pass Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 207967 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=207967&action=edit Bug 43795: Add REST API routes for MARC modification templates Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 Miranda Nero <mnero@oslri.net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mnero@oslri.net -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #207966|0 |1 is obsolete| | Attachment #207967|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 --- Comment #3 from David Nind <david@davidnind.com> --- Created attachment 208400 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208400&action=edit Bug 43795: Add Koha::MarcModificationTemplate(s) object classes This patch adds Koha::MarcModificationTemplate and Koha::MarcModificationTemplates object classes on top of the marc_modification_templates table, along with unit tests. The next patch adds REST API routes built on these classes. Test plan: 1. Apply both patches of this bug 2. yarn build; restart_all 3. prove t/db_dependent/Koha/MarcModificationTemplates.t \ t/db_dependent/api/v1/marc_modification_templates.t 4. Both pass Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 --- Comment #4 from David Nind <david@davidnind.com> --- Created attachment 208401 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208401&action=edit Bug 43795: Add REST API routes for MARC modification templates Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |release-notes-needed CC| |lucas@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Failed QA CC| |andrew@bywatersolutions.com --- Comment #5 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- xt/api.t fails with this code: xt/api.t .. 3/8 # Failed test 'No errors in 400 definitions in the spec' # at xt/api.t line 174. # got: '2' # expected: '0' get /marc_modification_templates/{marc_modification_template_id} -> 'description' does not start with 'Bad request': (Default response.) get /marc_modification_templates/{marc_modification_template_id} -> '$ref' is not '#/definitions/error': (#/definitions/DefaultResponse) # Looks like you failed 1 test of 1. # Failed test '400 response tests' # at xt/api.t line 179. xt/api.t .. 6/8 # Looks like you failed 1 test of 8. xt/api.t .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/8 subtests Test Summary Report ------------------- xt/api.t (Wstat: 256 (exited 1) Tests: 8 Failed: 1) Failed test: 5 Non-zero exit status: 1 Files=1, Tests=8, 6 wallclock secs ( 0.02 usr 0.01 sys + 5.70 cusr 0.30 csys = 6.03 CPU) Result: FAIL -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208400|0 |1 is obsolete| | Attachment #208401|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 --- Comment #6 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210786 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210786&action=edit Bug 43795: Add Koha::MarcModificationTemplate(s) object classes This patch adds Koha::MarcModificationTemplate and Koha::MarcModificationTemplates object classes on top of the marc_modification_templates table, along with unit tests. The next patch adds REST API routes built on these classes. Test plan: 1. Apply both patches of this bug 2. yarn build; restart_all 3. prove t/db_dependent/Koha/MarcModificationTemplates.t \ t/db_dependent/api/v1/marc_modification_templates.t 4. Both pass Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 --- Comment #7 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210787 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210787&action=edit Bug 43795: Add REST API routes for MARC modification templates Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 --- Comment #8 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210788 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210788&action=edit Bug 43795: (follow-up) Document the 400 response of GET /marc_modification_templates/{marc_modification_template_id} The route has a path parameter, so a 400 response can be returned by the request validation. Without it documented, the default response was used, which xt/api.t rejects. To test: 1. Apply the patches 2. yarn build; restart_all 3. prove xt/api.t => SUCCESS: Tests pass! (before the patch: 'No errors in 400 definitions' fails for get /marc_modification_templates/{marc_modification_template_id}) 4. Sign off :-D Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Signed Off --- Comment #9 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Thanks Andrew, good catch. GET /marc_modification_templates/{marc_modification_template_id} has a path parameter, so the request validation can return a 400, but the route did not document one and the default response was used. The new follow-up patch documents it as 'Bad request' with the error schema, like the other routes getting a single object. xt/api.t now passes, as do t/db_dependent/Koha/MarcModificationTemplates.t and t/db_dependent/api/v1/marc_modification_templates.t. All the patches are re-attached, rebased on current main, with the signed-off-by lines kept. Setting back to Signed Off for another look. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43795 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=44011 --- Comment #10 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Bug 44011 (PQA) also creates a marc mod templates object, so these will conflict. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org