From 635e65a3303a01b90bbc93695b24c98720683f10 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 2 Apr 2024 12:43:51 +0000 Subject: [PATCH] Bug 36483: Make API controllers use $c->objects->to_api This patch makes all controller methods using direct $object->to_api, rely on $c->objects->to_api. Direct ->to_api calling prevents things like embeds, +strings, etc to be dealt with correctly. In some cases this change reduces the code as the authors extracted the embed structure from the stash and passed it explicitly. I left out two Patrons.pm cases because I need to study it a bit more. To test: 1. Run: $ ktd --shell k$ prove t/db_dependent/api/v1 => SUCCESS: Tests pass 2. Apply this patch 3. Repeat 1 => SUCCESS: Tests still pass! 4. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer --- Koha/REST/V1/Acquisitions/Vendors.pm | 6 +++--- Koha/REST/V1/AdvancedEditorMacro.pm | 12 ++++++------ Koha/REST/V1/Auth/Identity/Provider/Domains.pm | 4 ++-- Koha/REST/V1/Auth/Identity/Providers.pm | 4 ++-- Koha/REST/V1/Authorities.pm | 4 ++-- Koha/REST/V1/BackgroundJobs.pm | 2 +- Koha/REST/V1/Biblios.pm | 8 ++++---- Koha/REST/V1/Biblios/ItemGroups.pm | 12 ++++-------- Koha/REST/V1/Biblios/ItemGroups/Items.pm | 4 +--- Koha/REST/V1/CashRegisters/Cashups.pm | 3 +-- Koha/REST/V1/Checkouts.pm | 6 +++--- Koha/REST/V1/Cities.pm | 6 +++--- Koha/REST/V1/Clubs/Holds.pm | 2 +- Koha/REST/V1/Config/SMTP/Servers.pm | 8 +++----- Koha/REST/V1/ERM/Agreements.pm | 4 ++-- Koha/REST/V1/ERM/EHoldings/Packages/Local.pm | 4 ++-- Koha/REST/V1/ERM/EHoldings/Titles/Local.pm | 4 ++-- Koha/REST/V1/ERM/EUsage/DefaultUsageReports.pm | 2 +- Koha/REST/V1/ERM/EUsage/UsageDataProviders.pm | 4 ++-- Koha/REST/V1/ERM/Licenses.pm | 4 ++-- Koha/REST/V1/Holds.pm | 4 ++-- Koha/REST/V1/Illrequests.pm | 2 +- Koha/REST/V1/ImportBatchProfiles.pm | 4 ++-- Koha/REST/V1/Libraries.pm | 4 ++-- Koha/REST/V1/Patrons/Account.pm | 8 ++++---- Koha/REST/V1/Patrons/Attributes.pm | 6 +++--- Koha/REST/V1/Preservation/Processings.pm | 4 ++-- Koha/REST/V1/Preservation/Trains.pm | 4 ++-- Koha/REST/V1/Quotes.pm | 6 +++--- Koha/REST/V1/ReturnClaims.pm | 6 +++--- Koha/REST/V1/SearchFilter.pm | 6 +++--- Koha/REST/V1/Suggestions.pm | 4 ++-- Koha/REST/V1/Tickets.pm | 8 ++++---- Koha/REST/V1/TransferLimits.pm | 4 ++-- 34 files changed, 82 insertions(+), 91 deletions(-) diff --git a/Koha/REST/V1/Acquisitions/Vendors.pm b/Koha/REST/V1/Acquisitions/Vendors.pm index 5ac4833931..d36801b74d 100644 --- a/Koha/REST/V1/Acquisitions/Vendors.pm +++ b/Koha/REST/V1/Acquisitions/Vendors.pm @@ -73,7 +73,7 @@ sub get { return try { return $c->render( status => 200, - openapi => $vendor->to_api + openapi => $c->objects->to_api($vendor), ); } catch { @@ -97,7 +97,7 @@ sub add { $c->res->headers->location($c->req->url->to_string . '/' . $vendor->id ); return $c->render( status => 201, - openapi => $vendor->to_api + openapi => $c->objects->to_api($vendor), ); } catch { @@ -122,7 +122,7 @@ sub update { $vendor->store(); return $c->render( status => 200, - openapi => $vendor->to_api + openapi => $c->objects->to_api($vendor), ); } catch { diff --git a/Koha/REST/V1/AdvancedEditorMacro.pm b/Koha/REST/V1/AdvancedEditorMacro.pm index 093b078605..1ac1c7806e 100644 --- a/Koha/REST/V1/AdvancedEditorMacro.pm +++ b/Koha/REST/V1/AdvancedEditorMacro.pm @@ -84,7 +84,7 @@ sub get { }); } - return $c->render( status => 200, openapi => $macro->to_api ); + return $c->render( status => 200, openapi => $c->objects->to_api($macro) ); } =head3 get_shared @@ -108,7 +108,7 @@ sub get_shared { error => "This macro is not shared, you must access it via advanced_editor/macros" }); } - return $c->render( status => 200, openapi => $macro->to_api ); + return $c->render( status => 200, openapi => $c->objects->to_api($macro) ); } =head3 add @@ -133,7 +133,7 @@ sub add { $c->res->headers->location( $c->req->url->to_string . '/' . $macro->id ); return $c->render( status => 201, - openapi => $macro->to_api + openapi => $c->objects->to_api($macro), ); } catch { @@ -162,7 +162,7 @@ sub add_shared { $c->res->headers->location( $c->req->url->to_string . '/' . $macro->id ); return $c->render( status => 201, - openapi => $macro->to_api + openapi => $c->objects->to_api($macro), ); } catch { @@ -202,7 +202,7 @@ sub update { return try { $macro->set_from_api( $body ); $macro->store->discard_changes; - return $c->render( status => 200, openapi => $macro->to_api ); + return $c->render( status => 200, openapi => $c->objects->to_api($macro), ); } catch { $c->unhandled_exception($_); @@ -235,7 +235,7 @@ sub update_shared { return try { $macro->set_from_api( $body ); $macro->store->discard_changes; - return $c->render( status => 200, openapi => $macro->to_api ); + return $c->render( status => 200, openapi => $c->objects->to_api($macro), ); } catch { $c->unhandled_exception($_); diff --git a/Koha/REST/V1/Auth/Identity/Provider/Domains.pm b/Koha/REST/V1/Auth/Identity/Provider/Domains.pm index 8ab5304a92..de7be5557b 100644 --- a/Koha/REST/V1/Auth/Identity/Provider/Domains.pm +++ b/Koha/REST/V1/Auth/Identity/Provider/Domains.pm @@ -129,7 +129,7 @@ sub add { $c->res->headers->location( $c->req->url->to_string . '/' . $domain->id ); return $c->render( status => 201, - openapi => $domain->to_api + openapi => $c->objects->to_api($domain), ); } ); @@ -184,7 +184,7 @@ sub update { return $c->render( status => 200, - openapi => $domain->to_api + openapi => $c->objects->to_api($domain), ); } ); diff --git a/Koha/REST/V1/Auth/Identity/Providers.pm b/Koha/REST/V1/Auth/Identity/Providers.pm index aeefb0320e..33dc6d18da 100644 --- a/Koha/REST/V1/Auth/Identity/Providers.pm +++ b/Koha/REST/V1/Auth/Identity/Providers.pm @@ -115,7 +115,7 @@ sub add { $c->res->headers->location( $c->req->url->to_string . '/' . $provider->identity_provider_id ); return $c->render( status => 201, - openapi => $provider->to_api + openapi => $c->objects->to_api($provider), ); } ); @@ -178,7 +178,7 @@ sub update { return $c->render( status => 200, - openapi => $provider->to_api + openapi => $c->objects->to_api($provider), ); } ); diff --git a/Koha/REST/V1/Authorities.pm b/Koha/REST/V1/Authorities.pm index a671c81d1c..bfc15f0e69 100644 --- a/Koha/REST/V1/Authorities.pm +++ b/Koha/REST/V1/Authorities.pm @@ -55,7 +55,7 @@ sub get { if ( $c->req->headers->accept =~ m/application\/json/ ) { return $c->render( status => 200, - json => $authority->to_api + json => $c->objects->to_api($authority), ); } else { @@ -269,7 +269,7 @@ sub list { if ( $c->req->headers->accept =~ m/application\/json(;.*)?$/ ) { return $c->render( status => 200, - json => $authorities->to_api + json => $c->objects->to_api($authorities), ); } elsif ( diff --git a/Koha/REST/V1/BackgroundJobs.pm b/Koha/REST/V1/BackgroundJobs.pm index eb672dbc9c..f56397db68 100644 --- a/Koha/REST/V1/BackgroundJobs.pm +++ b/Koha/REST/V1/BackgroundJobs.pm @@ -89,7 +89,7 @@ sub get { return $c->render( status => 200, - openapi => $job->to_api + openapi => $c->objects->to_api($job), ); } catch { diff --git a/Koha/REST/V1/Biblios.pm b/Koha/REST/V1/Biblios.pm index edb5165314..541e383eb1 100644 --- a/Koha/REST/V1/Biblios.pm +++ b/Koha/REST/V1/Biblios.pm @@ -70,7 +70,7 @@ sub get { if ( $c->req->headers->accept =~ m/application\/json/ ) { return $c->render( status => 200, - json => $biblio->to_api + json => $c->objects->to_api($biblio), ); } else { @@ -416,7 +416,7 @@ sub add_item { $c->render( status => 201, - openapi => $item->to_api + openapi => $c->objects->to_api($item), ); } catch { @@ -471,8 +471,8 @@ sub update_item { $item->store->discard_changes; $c->render( - status => 200, - openapi => $item->to_api + status => 200, + openapi => $c->objects->to_api($item), ); } catch { diff --git a/Koha/REST/V1/Biblios/ItemGroups.pm b/Koha/REST/V1/Biblios/ItemGroups.pm index c38de5251e..8dc4a16c1a 100644 --- a/Koha/REST/V1/Biblios/ItemGroups.pm +++ b/Koha/REST/V1/Biblios/ItemGroups.pm @@ -46,15 +46,11 @@ sub list { my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); return try { -#my $item_groups_set = Koha::Biblio::ItemGroups->new; - my $item_groups_set = $biblio->item_groups; - my $item_groups = $c->objects->search( $item_groups_set ); return $c->render( status => 200, - openapi => $item_groups + openapi => $c->objects->search( $biblio->item_groups ), ); - } - catch { + } catch { $c->unhandled_exception($_); }; } @@ -122,7 +118,7 @@ sub add { return $c->render( status => 201, - openapi => $item_group->to_api + openapi => $c->objects->to_api($item_group), ); } catch { @@ -172,7 +168,7 @@ sub update { return $c->render( status => 200, - openapi => $item_group->to_api + openapi => $c->objects->to_api($item_group), ); } catch { diff --git a/Koha/REST/V1/Biblios/ItemGroups/Items.pm b/Koha/REST/V1/Biblios/ItemGroups/Items.pm index c241962207..10d3f021ea 100644 --- a/Koha/REST/V1/Biblios/ItemGroups/Items.pm +++ b/Koha/REST/V1/Biblios/ItemGroups/Items.pm @@ -71,11 +71,9 @@ sub add { $c->res->headers->location( $c->req->url->to_string . '/' . $item_id ); - my $embed = $c->stash('koha.embed'); - return $c->render( status => 201, - openapi => $item_group->to_api({ embed => $embed }) + openapi => $c->objects->to_api($item_group), ); } catch { diff --git a/Koha/REST/V1/CashRegisters/Cashups.pm b/Koha/REST/V1/CashRegisters/Cashups.pm index f3cf06dae7..25aa4abf87 100644 --- a/Koha/REST/V1/CashRegisters/Cashups.pm +++ b/Koha/REST/V1/CashRegisters/Cashups.pm @@ -78,10 +78,9 @@ sub get { ); } - my $embed = $c->stash('koha.embed'); return $c->render( status => 200, - openapi => $cashup->to_api( { embed => $embed } ) + openapi => $c->objects->to_api($cashup), ); } catch { diff --git a/Koha/REST/V1/Checkouts.pm b/Koha/REST/V1/Checkouts.pm index a7749f1210..db3bee3c26 100644 --- a/Koha/REST/V1/Checkouts.pm +++ b/Koha/REST/V1/Checkouts.pm @@ -93,7 +93,7 @@ sub get { return try { return $c->render( status => 200, - openapi => $checkout->to_api + openapi => $c->objects->to_api($checkout), ); } catch { @@ -269,7 +269,7 @@ sub add { $c->req->url->to_string . '/' . $checkout->id ); return $c->render( status => 201, - openapi => $checkout->to_api + openapi => $c->objects->to_api($checkout), ); } else { @@ -363,7 +363,7 @@ sub renew { $c->res->headers->location( $c->req->url->to_string ); return $c->render( status => 201, - openapi => $checkout->to_api + openapi => $c->objects->to_api($checkout), ); } catch { diff --git a/Koha/REST/V1/Cities.pm b/Koha/REST/V1/Cities.pm index fccb013b24..a13c9680d7 100644 --- a/Koha/REST/V1/Cities.pm +++ b/Koha/REST/V1/Cities.pm @@ -58,7 +58,7 @@ sub get { openapi => { error => "City not found" } ); } - return $c->render( status => 200, openapi => $city->to_api ); + return $c->render( status => 200, openapi => $c->objects->to_api($city), ); } catch { $c->unhandled_exception($_); @@ -78,7 +78,7 @@ sub add { $c->res->headers->location( $c->req->url->to_string . '/' . $city->cityid ); return $c->render( status => 201, - openapi => $city->to_api + openapi => $c->objects->to_api($city), ); } catch { @@ -103,7 +103,7 @@ sub update { return try { $city->set_from_api( $c->req->json ); $city->store(); - return $c->render( status => 200, openapi => $city->to_api ); + return $c->render( status => 200, openapi => $c->objects->to_api($city), ); } catch { $c->unhandled_exception($_); diff --git a/Koha/REST/V1/Clubs/Holds.pm b/Koha/REST/V1/Clubs/Holds.pm index d2111f9cee..d202657f99 100644 --- a/Koha/REST/V1/Clubs/Holds.pm +++ b/Koha/REST/V1/Clubs/Holds.pm @@ -117,7 +117,7 @@ sub add { return $c->render( status => 201, - openapi => $club_hold->to_api + openapi => $c->objects->to_api($club_hold), ); } catch { diff --git a/Koha/REST/V1/Config/SMTP/Servers.pm b/Koha/REST/V1/Config/SMTP/Servers.pm index c5974e929a..09422134a3 100644 --- a/Koha/REST/V1/Config/SMTP/Servers.pm +++ b/Koha/REST/V1/Config/SMTP/Servers.pm @@ -70,11 +70,9 @@ sub get { ); } - my $embed = $c->stash('koha.embed'); - return $c->render( status => 200, - openapi => $smtp_server->to_api({ embed => $embed }) + openapi => $c->objects->to_api($smtp_server), ); } catch { @@ -100,7 +98,7 @@ sub add { return $c->render( status => 201, - openapi => $smtp_server->to_api + openapi => $c->objects->to_api($smtp_server), ); } catch { @@ -144,7 +142,7 @@ sub update { return $c->render( status => 200, - openapi => $smtp_server->to_api + openapi => $c->objects->to_api($smtp_server), ); } catch { diff --git a/Koha/REST/V1/ERM/Agreements.pm b/Koha/REST/V1/ERM/Agreements.pm index d44c8198a4..71096762ed 100644 --- a/Koha/REST/V1/ERM/Agreements.pm +++ b/Koha/REST/V1/ERM/Agreements.pm @@ -112,7 +112,7 @@ sub add { $c->res->headers->location($c->req->url->to_string . '/' . $agreement->agreement_id); return $c->render( status => 201, - openapi => $agreement->to_api + openapi => $c->objects->to_api($agreement), ); } ); @@ -200,7 +200,7 @@ sub update { $c->res->headers->location($c->req->url->to_string . '/' . $agreement->agreement_id); return $c->render( status => 200, - openapi => $agreement->to_api + openapi => $c->objects->to_api($agreement), ); } ); diff --git a/Koha/REST/V1/ERM/EHoldings/Packages/Local.pm b/Koha/REST/V1/ERM/EHoldings/Packages/Local.pm index ff310d6fe1..7d966ce891 100644 --- a/Koha/REST/V1/ERM/EHoldings/Packages/Local.pm +++ b/Koha/REST/V1/ERM/EHoldings/Packages/Local.pm @@ -100,7 +100,7 @@ sub add { $c->res->headers->location($c->req->url->to_string . '/' . $package->package_id); return $c->render( status => 201, - openapi => $package->to_api + openapi => $c->objects->to_api($package), ); } ); @@ -179,7 +179,7 @@ sub update { $c->res->headers->location($c->req->url->to_string . '/' . $package->package_id); return $c->render( status => 200, - openapi => $package->to_api + openapi => $c->objects->to_api($package), ); } ); diff --git a/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm b/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm index 0aab8af865..eddf02f410 100644 --- a/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm +++ b/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm @@ -100,7 +100,7 @@ sub add { $c->res->headers->location($c->req->url->to_string . '/' . $title->title_id); return $c->render( status => 201, - openapi => $title->to_api + openapi => $c->objects->to_api($title), ); } ); @@ -175,7 +175,7 @@ sub update { $c->res->headers->location($c->req->url->to_string . '/' . $title->title_id); return $c->render( status => 200, - openapi => $title->to_api + openapi => $c->objects->to_api($title), ); } ); diff --git a/Koha/REST/V1/ERM/EUsage/DefaultUsageReports.pm b/Koha/REST/V1/ERM/EUsage/DefaultUsageReports.pm index 7d87c14bb1..4fa760673a 100644 --- a/Koha/REST/V1/ERM/EUsage/DefaultUsageReports.pm +++ b/Koha/REST/V1/ERM/EUsage/DefaultUsageReports.pm @@ -69,7 +69,7 @@ sub add { $c->req->url->to_string . '/' . $default_report->erm_default_usage_report_id ); return $c->render( status => 201, - openapi => $default_report->to_api + openapi => $c->objects->to_api($default_report), ); } ); diff --git a/Koha/REST/V1/ERM/EUsage/UsageDataProviders.pm b/Koha/REST/V1/ERM/EUsage/UsageDataProviders.pm index 8c4a817301..193bf43d1a 100644 --- a/Koha/REST/V1/ERM/EUsage/UsageDataProviders.pm +++ b/Koha/REST/V1/ERM/EUsage/UsageDataProviders.pm @@ -161,7 +161,7 @@ sub add { $c->req->url->to_string . '/' . $usage_data_provider->erm_usage_data_provider_id ); return $c->render( status => 201, - openapi => $usage_data_provider->to_api + openapi => $c->objects->to_api($usage_data_provider), ); } ); @@ -227,7 +227,7 @@ sub update { $c->req->url->to_string . '/' . $usage_data_provider->erm_usage_data_provider_id ); return $c->render( status => 200, - openapi => $usage_data_provider->to_api + openapi => $c->objects->to_api($usage_data_provider), ); } ); diff --git a/Koha/REST/V1/ERM/Licenses.pm b/Koha/REST/V1/ERM/Licenses.pm index 616c10331c..4e15d703ce 100644 --- a/Koha/REST/V1/ERM/Licenses.pm +++ b/Koha/REST/V1/ERM/Licenses.pm @@ -99,7 +99,7 @@ sub add { $c->res->headers->location($c->req->url->to_string . '/' . $license->license_id); return $c->render( status => 201, - openapi => $license->to_api + openapi => $c->objects->to_api($license), ); } ); @@ -181,7 +181,7 @@ sub update { $c->res->headers->location($c->req->url->to_string . '/' . $license->license_id); return $c->render( status => 200, - openapi => $license->to_api + openapi => $c->objects->to_api($license), ); } ); diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm index ff162cd945..e34d23199b 100644 --- a/Koha/REST/V1/Holds.pm +++ b/Koha/REST/V1/Holds.pm @@ -213,7 +213,7 @@ sub add { return $c->render( status => 201, - openapi => $hold->to_api + openapi => $c->objects->to_api($hold), ); } catch { @@ -291,7 +291,7 @@ sub edit { return $c->render( status => 200, - openapi => $hold->to_api + openapi => $c->objects->to_api($hold), ); } catch { diff --git a/Koha/REST/V1/Illrequests.pm b/Koha/REST/V1/Illrequests.pm index 6b8d990904..08020b8961 100644 --- a/Koha/REST/V1/Illrequests.pm +++ b/Koha/REST/V1/Illrequests.pm @@ -98,7 +98,7 @@ sub add { $c->res->headers->location($c->req->url->to_string . '/' . $new_req->illrequest_id); return $c->render( status => 201, - openapi => $new_req->to_api + openapi => $c->objects->to_api($new_req), ); } ); diff --git a/Koha/REST/V1/ImportBatchProfiles.pm b/Koha/REST/V1/ImportBatchProfiles.pm index 9d951ea399..562bae39a2 100644 --- a/Koha/REST/V1/ImportBatchProfiles.pm +++ b/Koha/REST/V1/ImportBatchProfiles.pm @@ -70,7 +70,7 @@ sub add { my $profile = Koha::ImportBatchProfile->new_from_api( $body )->store; return $c->render( status => 201, - openapi => $profile->to_api + openapi => $c->objects->to_api($profile), ); } catch { @@ -100,7 +100,7 @@ sub edit { return $c->render( status => 200, - openapi => $profile->to_api + openapi => $c->objects->to_api($profile), ); } catch { diff --git a/Koha/REST/V1/Libraries.pm b/Koha/REST/V1/Libraries.pm index 55aa426974..5eb042a0c1 100644 --- a/Koha/REST/V1/Libraries.pm +++ b/Koha/REST/V1/Libraries.pm @@ -97,7 +97,7 @@ sub add { return $c->render( status => 201, - openapi => $library->to_api + openapi => $c->objects->to_api($library), ); } catch { @@ -136,7 +136,7 @@ sub update { $library->store(); return $c->render( status => 200, - openapi => $library->to_api + openapi => $c->objects->to_api($library), ); } catch { diff --git a/Koha/REST/V1/Patrons/Account.pm b/Koha/REST/V1/Patrons/Account.pm index 2cf643029c..7e941c3326 100644 --- a/Koha/REST/V1/Patrons/Account.pm +++ b/Koha/REST/V1/Patrons/Account.pm @@ -62,11 +62,11 @@ sub get { balance => $account->balance, outstanding_debits => { total => $debits->total_outstanding, - lines => $debits->to_api + lines => $c->objects->to_api($debits), }, outstanding_credits => { total => $credits->total_outstanding, - lines => $credits->to_api + lines => $c->objects->to_api($credits), } } ); @@ -182,7 +182,7 @@ sub add_credit { return $c->render( status => 201, - openapi => $credit->to_api + openapi => $c->objects->to_api($credit), ); } catch { @@ -255,7 +255,7 @@ sub add_debit { return $c->render( status => 201, - openapi => $debit->to_api + openapi => $c->objects->to_api($debit), ); } catch { diff --git a/Koha/REST/V1/Patrons/Attributes.pm b/Koha/REST/V1/Patrons/Attributes.pm index 3d1e347073..269cab4856 100644 --- a/Koha/REST/V1/Patrons/Attributes.pm +++ b/Koha/REST/V1/Patrons/Attributes.pm @@ -99,7 +99,7 @@ sub add { $c->res->headers->location( $c->req->url->to_string . '/' . $attribute->id ); return $c->render( status => 201, - openapi => $attribute->to_api + openapi => $c->objects->to_api($attribute), ); } catch { @@ -175,7 +175,7 @@ sub overwrite { return $c->render( status => 200, - openapi => $attributes->to_api + openapi => $c->objects->to_api($attributes), ); } catch { @@ -256,7 +256,7 @@ sub update { return $c->render( status => 200, - openapi => $attribute->to_api + openapi => $c->objects->to_api($attribute), ); } catch { diff --git a/Koha/REST/V1/Preservation/Processings.pm b/Koha/REST/V1/Preservation/Processings.pm index 0aeafebf56..70e1f9d581 100644 --- a/Koha/REST/V1/Preservation/Processings.pm +++ b/Koha/REST/V1/Preservation/Processings.pm @@ -96,7 +96,7 @@ sub add { $c->res->headers->location( $c->req->url->to_string . '/' . $processing->processing_id ); return $c->render( status => 201, - openapi => $processing->to_api + openapi => $c->objects->to_api($processing), ); } ); @@ -165,7 +165,7 @@ sub update { $c->res->headers->location( $c->req->url->to_string . '/' . $processing->processing_id ); return $c->render( status => 200, - openapi => $processing->to_api + openapi => $c->objects->to_api($processing), ); } ); diff --git a/Koha/REST/V1/Preservation/Trains.pm b/Koha/REST/V1/Preservation/Trains.pm index 49326b0a09..a93f7601ae 100644 --- a/Koha/REST/V1/Preservation/Trains.pm +++ b/Koha/REST/V1/Preservation/Trains.pm @@ -96,7 +96,7 @@ sub add { $c->res->headers->location( $c->req->url->to_string . '/' . $train->train_id ); return $c->render( status => 201, - openapi => $train->to_api + openapi => $c->objects->to_api($train), ); } ); @@ -162,7 +162,7 @@ sub update { $c->res->headers->location( $c->req->url->to_string . '/' . $train->train_id ); return $c->render( status => 200, - openapi => $train->to_api + openapi => $c->objects->to_api($train), ); } ); diff --git a/Koha/REST/V1/Quotes.pm b/Koha/REST/V1/Quotes.pm index 51a35c9602..8884512203 100644 --- a/Koha/REST/V1/Quotes.pm +++ b/Koha/REST/V1/Quotes.pm @@ -60,7 +60,7 @@ sub get { ); } - return $c->render( status => 200, openapi => $quote->to_api ); + return $c->render( status => 200, openapi => $c->objects->to_api($quote), ); } catch { $c->unhandled_exception($_); @@ -80,7 +80,7 @@ sub add { $c->res->headers->location( $c->req->url->to_string . '/' . $quote->id ); return $c->render( status => 201, - openapi => $quote->to_api + openapi => $c->objects->to_api($quote), ); } catch { @@ -105,7 +105,7 @@ sub update { return try { $quote->set_from_api( $c->req->json ); $quote->store(); - return $c->render( status => 200, openapi => $quote->to_api ); + return $c->render( status => 200, openapi => $c->objects->to_api($quote), ); } catch { $c->unhandled_exception($_); diff --git a/Koha/REST/V1/ReturnClaims.pm b/Koha/REST/V1/ReturnClaims.pm index ad9a61acf1..e3ce9b30f1 100644 --- a/Koha/REST/V1/ReturnClaims.pm +++ b/Koha/REST/V1/ReturnClaims.pm @@ -69,7 +69,7 @@ sub claim_returned { $c->res->headers->location($c->req->url->to_string . '/' . $claim->id ); return $c->render( status => 201, - openapi => $claim->to_api + openapi => $c->objects->to_api($claim), ); } catch { @@ -128,7 +128,7 @@ sub update_notes { return $c->render( status => 200, - openapi => $claim->to_api + openapi => $c->objects->to_api($claim), ); } catch { @@ -174,7 +174,7 @@ sub resolve_claim { return $c->render( status => 200, - openapi => $claim->to_api + openapi => $c->objects->to_api($claim), ); } catch { diff --git a/Koha/REST/V1/SearchFilter.pm b/Koha/REST/V1/SearchFilter.pm index ce912b82a3..895d3cf472 100644 --- a/Koha/REST/V1/SearchFilter.pm +++ b/Koha/REST/V1/SearchFilter.pm @@ -64,7 +64,7 @@ sub get { openapi => { error => "Search filter not found" } ); } - return $c->render( status => 200, openapi => $filter->to_api ); + return $c->render( status => 200, openapi => $c->objects->to_api($filter), ); } =head3 add @@ -82,7 +82,7 @@ sub add { $c->res->headers->location( $c->req->url->to_string . '/' . $filter->id ); return $c->render( status => 201, - openapi => $filter->to_api + openapi => $c->objects->to_api($filter), ); } catch { @@ -115,7 +115,7 @@ sub update { return try { $filter->set_from_api( $c->req->json ); $filter->store->discard_changes; - return $c->render( status => 200, openapi => $filter->to_api ); + return $c->render( status => 200, openapi => $c->objects->to_api($filter), ); } catch { $c->unhandled_exception($_); diff --git a/Koha/REST/V1/Suggestions.pm b/Koha/REST/V1/Suggestions.pm index ba21194a54..b6432e2a5f 100644 --- a/Koha/REST/V1/Suggestions.pm +++ b/Koha/REST/V1/Suggestions.pm @@ -149,7 +149,7 @@ sub add { return $c->render( status => 201, - openapi => $suggestion->to_api + openapi => $c->objects->to_api($suggestion), ); } catch { @@ -182,7 +182,7 @@ sub update { return $c->render( status => 200, - openapi => $suggestion->to_api + openapi => $c->objects->to_api($suggestion), ); } catch { diff --git a/Koha/REST/V1/Tickets.pm b/Koha/REST/V1/Tickets.pm index a63ff3539d..b42cee6412 100644 --- a/Koha/REST/V1/Tickets.pm +++ b/Koha/REST/V1/Tickets.pm @@ -63,7 +63,7 @@ sub get { ); } - return $c->render( status => 200, openapi => $ticket->to_api ); + return $c->render( status => 200, openapi => $c->objects->to_api($ticket), ); } catch { $c->unhandled_exception($_); @@ -92,7 +92,7 @@ sub add { $c->req->url->to_string . '/' . $ticket->id ); return $c->render( status => 201, - openapi => $ticket->to_api + openapi => $c->objects->to_api($ticket), ); } catch { @@ -119,7 +119,7 @@ sub update { return try { $ticket->set_from_api( $c->req->json ); $ticket->store(); - return $c->render( status => 200, openapi => $ticket->to_api ); + return $c->render( status => 200, openapi => $c->objects->to_api($ticket), ); } catch { $c->unhandled_exception($_); @@ -249,7 +249,7 @@ sub add_update { $c->req->url->to_string . '/' . $update->id ); return $c->render( status => 201, - openapi => $update->to_api + openapi => $c->objects->to_api($update), ); } catch { diff --git a/Koha/REST/V1/TransferLimits.pm b/Koha/REST/V1/TransferLimits.pm index a9abcb1e80..8f625fa9ec 100644 --- a/Koha/REST/V1/TransferLimits.pm +++ b/Koha/REST/V1/TransferLimits.pm @@ -76,7 +76,7 @@ sub add { return $c->render( status => 201, - openapi => $transfer_limit->to_api + openapi => $c->objects->to_api($transfer_limit), ); } catch { @@ -187,7 +187,7 @@ sub batch_add { my $transfer_limit = Koha::Item::Transfer::Limit->new_from_api($limit_params); $transfer_limit->store; - push( @results, $transfer_limit->to_api() ); + push( @results, $c->objects->to_api($transfer_limit) ); } } -- 2.39.5