From 87a3ea47f8384f8cb5859d08752c296293860448 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 --- 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 5603e60294..ce47b8a1e9 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); + my @reserved_words = qw( _match _order_by _order_by[] _page _per_page q query x-koha-query 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.20.1