From d091c172fa695bb9d5fb921cdf50782423dabc63 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 6 Jun 2025 12:08:56 -0300 Subject: [PATCH] Bug 29668: Adapt to current guidelines The added patches make some changes: * $c->req->json is used to access the request body, as explained by the Mojolicious OpenAPI plugin author it should be done. * Instead of calling `$basket->to_api` we use the `$c->objects->to_api` helper which deals with calling context (embeds, etc). Otherwise it would require doing it manually if embeds are added. * Tests are grouped together the same way the rest of them are. To test: 1. Apply this patches 2. Run: $ ktd --shell k$ prove t/db_dependent/api/v1/acquisitions_baskets.t => SUCCESS: Tests pass! Signed-off-by: Tomas Cohen Arazi --- Koha/REST/V1/Acquisitions/Baskets.pm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Koha/REST/V1/Acquisitions/Baskets.pm b/Koha/REST/V1/Acquisitions/Baskets.pm index 35dbea45b36..59988ec028f 100644 --- a/Koha/REST/V1/Acquisitions/Baskets.pm +++ b/Koha/REST/V1/Acquisitions/Baskets.pm @@ -88,16 +88,14 @@ sub add { my $c = shift->openapi->valid_input or return; return try { - my $basket = Koha::Acquisition::Basket->new_from_api( $c->validation->param('body') ); - $basket->store->discard_changes; + my $basket = Koha::Acquisition::Basket->new_from_api( $c->req->json ); + $basket->store; - $c->res->headers->location( - $c->req->url->to_string . '/' . $basket->basketno - ); + $c->res->headers->location( $c->req->url->to_string . '/' . $basket->basketno ); return $c->render( status => 201, - openapi => $basket->to_api + openapi => $c->objects->to_api($basket), ); } catch { $c->unhandled_exception($_); -- 2.49.0