From 75dc30cf42b4a1b403bbb704aee3900e1bc9afa8 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 8 Jun 2023 13:11:32 +0000 Subject: [PATCH] Bug 33960: Add deleted option ot biblios endpoint This patch adds a 'deleted' parameter to the biblios endpoint. If this parameter is passed the API will return deleted biblios rather than current ones To test: 1 - Apply patch 2 - GET http://localhost:8081/api/v1/biblios 3 - Confirm you can search and page 4 - add 'deleted' param to query 5 - Confirm you get dleted biblios information 6 - Confirm searching and paging work as expected --- Koha/REST/V1/Biblios.pm | 7 ++++++- api/v1/swagger/paths/biblios.yaml | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Koha/REST/V1/Biblios.pm b/Koha/REST/V1/Biblios.pm index 6457d49d7a..5aa09093b8 100644 --- a/Koha/REST/V1/Biblios.pm +++ b/Koha/REST/V1/Biblios.pm @@ -20,6 +20,7 @@ use Modern::Perl; use Mojo::Base 'Mojolicious::Controller'; use Koha::Biblios; +use Koha::Old::Biblios; use Koha::DateUtils; use Koha::Ratings; use Koha::RecordProcessor; @@ -797,12 +798,16 @@ Controller function that handles retrieving a single biblio object sub list { my $c = shift->openapi->valid_input or return; + my $deleted = delete $c->validation->output->{deleted}; + my $attributes; $attributes = { prefetch => ['metadata'] } # don't prefetch metadata if not needed unless $c->req->headers->accept =~ m/application\/json/; - my $biblios = $c->objects->search_rs( Koha::Biblios->new ); + my $biblios = $deleted ? + $c->objects->search_rs( Koha::Old::Biblios->new ) : + $c->objects->search_rs( Koha::Biblios->new ); return try { diff --git a/api/v1/swagger/paths/biblios.yaml b/api/v1/swagger/paths/biblios.yaml index fa98f152a5..6baa494e77 100644 --- a/api/v1/swagger/paths/biblios.yaml +++ b/api/v1/swagger/paths/biblios.yaml @@ -67,6 +67,10 @@ - biblios summary: List biblios parameters: + - name: deleted + in: query + description: If information on deleted objects is requested + type: boolean - $ref: "../swagger.yaml#/parameters/page" - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/match" -- 2.30.2