Bugzilla – Attachment 164266 Details for
Bug 36483
Calling $object->to_api directly should be avoided
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36483: Make API controllers use $c->objects->to_api
Bug-36483-Make-API-controllers-use-c-objects-toapi.patch (text/plain), 32.66 KB, created by
Tomás Cohen Arazi
on 2024-04-02 12:59:59 UTC
(
hide
)
Description:
Bug 36483: Make API controllers use $c->objects->to_api
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi
Created:
2024-04-02 12:59:59 UTC
Size:
32.66 KB
patch
obsolete
>From 348f8425ef0307dd22387c338250ae7d373b9fb2 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >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 <tomascohen@theke.io> >--- > 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 5ac48339313..d36801b74d9 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 093b0786052..1ac1c7806e4 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 8ab5304a922..de7be5557b8 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 aeefb0320ec..33dc6d18dad 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 a671c81d1c7..bfc15f0e69b 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 eb672dbc9c3..f56397db686 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 0f66754f830..49b449c3c1e 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 { >@@ -411,7 +411,7 @@ sub add_item { > > $c->render( > status => 201, >- openapi => $item->to_api >+ openapi => $c->objects->to_api($item), > ); > } > catch { >@@ -466,8 +466,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 c38de5251ed..8dc4a16c1a1 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 c241962207c..10d3f021ead 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 f3cf06dae79..25aa4abf879 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 a7749f1210e..db3bee3c268 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 fccb013b24d..a13c9680d75 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 d2111f9cee8..d202657f99b 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 c5974e929a5..09422134a33 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 d44c8198a4a..71096762ed2 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 ff310d6fe1c..7d966ce891e 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 0aab8af8659..eddf02f4102 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 7d87c14bb13..4fa760673a4 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 8c4a817301c..193bf43d1a2 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 616c10331cb..4e15d703cee 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 ff162cd9453..e34d23199ba 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 6b8d990904a..08020b89616 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 9d951ea399a..562bae39a2d 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 760648ccb18..db0cb3011de 100644 >--- a/Koha/REST/V1/Libraries.pm >+++ b/Koha/REST/V1/Libraries.pm >@@ -96,7 +96,7 @@ sub add { > > return $c->render( > status => 201, >- openapi => $library->to_api >+ openapi => $c->objects->to_api($library), > ); > } > catch { >@@ -135,7 +135,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 2cf643029cf..7e941c33260 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 3d1e347073e..269cab4856e 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 0aeafebf563..70e1f9d5817 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 49326b0a09e..a93f7601ae4 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 51a35c9602c..88845122039 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 ad9a61acf1d..e3ce9b30f15 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 ce912b82a30..895d3cf472a 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 ba21194a54b..b6432e2a5ff 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 a63ff3539de..b42cee64129 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 a9abcb1e808..8f625fa9ece 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.44.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36483
:
164264
|
164266
|
164267
|
164293
|
164294
|
164803
|
164804