From 57ad9a15cb9167481dd36bda81b44c11ec340909 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 4 Aug 2023 16:01:33 +0000 Subject: [PATCH] Bug 34431: Allow for x-koha-embed in ill/backends endpoint --- Koha/REST/V1/Illbackends.pm | 13 ++++++++++--- api/v1/swagger/paths/ill_backends.yaml | 12 +++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Koha/REST/V1/Illbackends.pm b/Koha/REST/V1/Illbackends.pm index 8b70d9368e..45b9c29922 100644 --- a/Koha/REST/V1/Illbackends.pm +++ b/Koha/REST/V1/Illbackends.pm @@ -40,15 +40,22 @@ sub list { my $config = Koha::Illrequest::Config->new; my $backends = $config->available_backends; + my $backend_module = Koha::Illbackend->new; my @data; foreach my $b (@$backends) { my $backend = Koha::Illrequest->new->load_backend($b); - push @data, - { + + my $embed = $backend_module->embed( + $b, + $c->req->headers->header('x-koha-embed') + ); + + my $return = { ill_backend_id => $b, capabilities => $backend->capabilities, - }; + }; + push @data, $embed ? { %$return, %$embed } : $return; } return $c->render( status => 200, openapi => \@data ); } diff --git a/api/v1/swagger/paths/ill_backends.yaml b/api/v1/swagger/paths/ill_backends.yaml index 874481a5ec..f076137527 100644 --- a/api/v1/swagger/paths/ill_backends.yaml +++ b/api/v1/swagger/paths/ill_backends.yaml @@ -6,7 +6,17 @@ tags: - ill_backends summary: List ILL backends - parameters: [] + parameters: + - name: x-koha-embed + in: header + required: false + description: Embed list sent as a request header + type: array + items: + type: string + enum: + - statuses+strings + collectionFormat: csv produces: - application/json responses: -- 2.30.2