Bug 30536: Refer to parameters enum
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 14 Apr 2022 11:22:27 +0000 (12:22 +0100)
committerFridolin Somers <fridolin.somers@biblibre.com>
Tue, 3 May 2022 21:19:51 +0000 (11:19 -1000)
This patch updates the stash_embed method to use the parameters hash
enum instead of the top level x-koha-embed custom definition. This way
we can remove the requirement for defining this list twice.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Koha/REST/Plugin/Query.pm

index 396af69..f14fa6f 100644 (file)
@@ -240,7 +240,11 @@ Merges parameters from $q_params into $filtered_params.
 
             my $spec = $args->{spec} // {};
 
-            my $embed_spec   = $spec->{'x-koha-embed'};
+            my $embed_spec;
+            for my $param (@{$spec->{parameters}}) {
+                next unless $param->{name} eq 'x-koha-embed';
+                $embed_spec = $param->{items}->{enum};
+            }
             my $embed_header = $c->req->headers->header('x-koha-embed');
 
             Koha::Exceptions::BadParameter->throw("Embedding objects is not allowed on this endpoint.")