From 6a3f1027ea33b38258088d1f651898facc6beb6c Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 24 Mar 2022 14:19:35 +0000 Subject: [PATCH] Bug 29810: Add 'x-koha-embed' to reserved words The maintainers of Mojolicious::Plugin::OpenAPI and friends fixed the problem with using collectionFormat for Headers in the upstream library. However, this highlighted an outstanding issue in our code when I ran the unit tests. We have not been stripping x-koha-embed at the query level as it did not exist in the reserved_words list. This patch resolves that and gets the acquisitions_orders test passing again. Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart Signed-off-by: Fridolin Somers --- Koha/REST/Plugin/Query.pm | 2 +- t/db_dependent/api/v1/acquisitions_orders.t | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Koha/REST/Plugin/Query.pm b/Koha/REST/Plugin/Query.pm index 5875d92a46..396af699b9 100644 --- a/Koha/REST/Plugin/Query.pm +++ b/Koha/REST/Plugin/Query.pm @@ -310,7 +310,7 @@ reference: https://metacpan.org/changes/distribution/JSON-Validator#L14 sub _reserved_words { - my @reserved_words = qw( _match _order_by _order_by[] _page _per_page q query x-koha-query x-koha-request-id ); + my @reserved_words = qw( _match _order_by _order_by[] _page _per_page q query x-koha-query x-koha-request-id x-koha-embed); return \@reserved_words; } diff --git a/t/db_dependent/api/v1/acquisitions_orders.t b/t/db_dependent/api/v1/acquisitions_orders.t index 3025c1856b..cee1aecb5e 100755 --- a/t/db_dependent/api/v1/acquisitions_orders.t +++ b/t/db_dependent/api/v1/acquisitions_orders.t @@ -113,7 +113,7 @@ subtest 'list() tests' => sub { my $query = { "biblio.isbn" => { "-like" => "\%SOMETHING\%" } }; $t->get_ok( "//$userid:$password@/api/v1/acquisitions/orders?q=" . encode_json($query) => {'x-koha-embed' => 'biblio'} ) - ->status_is( 200, "Embeddig biblio.isbn doesn't make it explode" ) + ->status_is( 200, "Embedding biblio and searching on biblio.isbn doesn't make it explode" ) ->json_has( "/0/biblio", "biblio object correctly embedded" ) ->json_is( "/0/biblio/isbn", 'SOMETHING', 'Filtering by a biblioitems column works!' ); -- 2.39.5