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: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Tomás Cohen Arazi 2025-11-05 13:49:36 -03:00 committed by Lucas Gass
parent ca8134f85d
commit ac9944f7b0
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 3 additions and 3 deletions

View File

@ -43,14 +43,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 );
return $c->render(
status => 201,
openapi => $basket->to_api
openapi => $c->objects->to_api($basket),
);
} catch {
$c->unhandled_exception($_);