From 3fc1f27524a4a0f0dfc6385b289c252502e45fd6 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 13 Jun 2023 11:27:07 -0300 Subject: [PATCH] Bug 33971: Remove x-koha-query header support This patch removes support for the `x-koha-query` header entirely from the codebase. For the purpose: - $c->objects->search is adjusted - Relevant tests are cleared/adapted - The OpenAPI spec gets the header removed To test: 1. Apply this patch and run: $ ktd --shell k$ prove t/db_dependent/Koha/REST/Plugin/Objects.t \ t/Koha/REST/Plugin/Query.t \ t/db_dependent/api/v1/*.t => SUCCESS: Tests pass! 2. Sign off :-D Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- Koha/REST/Plugin/Objects.pm | 7 +-- Koha/REST/Plugin/Query.pm | 2 +- .../swagger/paths/acquisitions_baskets.yaml | 1 - api/v1/swagger/paths/acquisitions_funds.yaml | 3 - api/v1/swagger/paths/acquisitions_orders.yaml | 1 - .../swagger/paths/acquisitions_vendors.yaml | 1 - .../swagger/paths/advancededitormacros.yaml | 1 - api/v1/swagger/paths/auth.yaml | 4 -- .../paths/authorised_value_categories.yaml | 1 - api/v1/swagger/paths/authorised_values.yaml | 1 - api/v1/swagger/paths/authorities.yaml | 1 - api/v1/swagger/paths/biblios.yaml | 5 -- api/v1/swagger/paths/biblios_item_groups.yaml | 1 - api/v1/swagger/paths/cash_registers.yaml | 1 - api/v1/swagger/paths/checkouts.yaml | 1 - api/v1/swagger/paths/cities.yaml | 1 - api/v1/swagger/paths/config_smtp_servers.yaml | 1 - api/v1/swagger/paths/erm_agreements.yaml | 1 - .../swagger/paths/erm_eholdings_packages.yaml | 1 - .../erm_eholdings_packages_resources.yaml | 1 - .../paths/erm_eholdings_resources.yaml | 1 - .../swagger/paths/erm_eholdings_titles.yaml | 1 - .../paths/erm_eholdings_titles_resources.yaml | 1 - api/v1/swagger/paths/erm_licenses.yaml | 1 - api/v1/swagger/paths/erm_users.yaml | 1 - api/v1/swagger/paths/holds.yaml | 2 - api/v1/swagger/paths/ill_requests.yaml | 1 - .../swagger/paths/import_batch_profiles.yaml | 1 - api/v1/swagger/paths/items.yaml | 4 -- api/v1/swagger/paths/jobs.yaml | 1 - api/v1/swagger/paths/libraries.yaml | 2 - api/v1/swagger/paths/patrons.yaml | 1 - api/v1/swagger/paths/patrons_account.yaml | 2 - .../paths/patrons_extended_attributes.yaml | 1 - api/v1/swagger/paths/patrons_holds.yaml | 1 - api/v1/swagger/paths/quotes.yaml | 1 - api/v1/swagger/paths/search_filters.yaml | 1 - api/v1/swagger/paths/suggestions.yaml | 2 - api/v1/swagger/paths/tickets.yaml | 2 - api/v1/swagger/paths/transfer_limits.yaml | 1 - api/v1/swagger/swagger.yaml | 7 --- t/db_dependent/Koha/REST/Plugin/Objects.t | 58 ++++++++----------- 42 files changed, 26 insertions(+), 103 deletions(-) diff --git a/Koha/REST/Plugin/Objects.pm b/Koha/REST/Plugin/Objects.pm index 94baf03753..ea562f7ec7 100644 --- a/Koha/REST/Plugin/Objects.pm +++ b/Koha/REST/Plugin/Objects.pm @@ -197,8 +197,7 @@ controller, and thus shouldn't be called twice in it. } if ( defined $reserved_params->{q} - || defined $reserved_params->{query} - || defined $reserved_params->{'x-koha-query'} ) + || defined $reserved_params->{query} ) { $filtered_params //= {}; @@ -226,10 +225,6 @@ controller, and thus shouldn't be called twice in it. if $reserved_params->{q}; } - push @query_params_array, - $json->decode( $reserved_params->{'x-koha-query'} ) - if defined $reserved_params->{'x-koha-query'}; - my $query_params; if ( scalar(@query_params_array) > 1 ) { diff --git a/Koha/REST/Plugin/Query.pm b/Koha/REST/Plugin/Query.pm index 432a0d8fab..7aa092fae2 100644 --- a/Koha/REST/Plugin/Query.pm +++ b/Koha/REST/Plugin/Query.pm @@ -315,7 +315,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 x-koha-embed); + my @reserved_words = qw( _match _order_by _order_by[] _page _per_page q query x-koha-request-id x-koha-embed); return \@reserved_words; } diff --git a/api/v1/swagger/paths/acquisitions_baskets.yaml b/api/v1/swagger/paths/acquisitions_baskets.yaml index 89b7d7e42b..0adf26de00 100644 --- a/api/v1/swagger/paths/acquisitions_baskets.yaml +++ b/api/v1/swagger/paths/acquisitions_baskets.yaml @@ -14,7 +14,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - name: x-koha-embed in: header required: false diff --git a/api/v1/swagger/paths/acquisitions_funds.yaml b/api/v1/swagger/paths/acquisitions_funds.yaml index 31f0455e5b..174b52d4d4 100644 --- a/api/v1/swagger/paths/acquisitions_funds.yaml +++ b/api/v1/swagger/paths/acquisitions_funds.yaml @@ -25,7 +25,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" responses: "200": @@ -75,7 +74,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - name: x-koha-embed in: header required: false @@ -128,7 +126,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - name: x-koha-embed in: header required: false diff --git a/api/v1/swagger/paths/acquisitions_orders.yaml b/api/v1/swagger/paths/acquisitions_orders.yaml index 8f5f35e669..260597281d 100644 --- a/api/v1/swagger/paths/acquisitions_orders.yaml +++ b/api/v1/swagger/paths/acquisitions_orders.yaml @@ -41,7 +41,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" - name: x-koha-embed in: header diff --git a/api/v1/swagger/paths/acquisitions_vendors.yaml b/api/v1/swagger/paths/acquisitions_vendors.yaml index 599b213cb0..7af2fbc48a 100644 --- a/api/v1/swagger/paths/acquisitions_vendors.yaml +++ b/api/v1/swagger/paths/acquisitions_vendors.yaml @@ -25,7 +25,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" - name: x-koha-embed in: header diff --git a/api/v1/swagger/paths/advancededitormacros.yaml b/api/v1/swagger/paths/advancededitormacros.yaml index 0cb4c34323..b6ad3c731a 100644 --- a/api/v1/swagger/paths/advancededitormacros.yaml +++ b/api/v1/swagger/paths/advancededitormacros.yaml @@ -35,7 +35,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" responses: "200": diff --git a/api/v1/swagger/paths/auth.yaml b/api/v1/swagger/paths/auth.yaml index 90765f1d20..04e89e6736 100644 --- a/api/v1/swagger/paths/auth.yaml +++ b/api/v1/swagger/paths/auth.yaml @@ -142,7 +142,6 @@ - $ref: ../swagger.yaml#/parameters/per_page - $ref: ../swagger.yaml#/parameters/q_param - $ref: ../swagger.yaml#/parameters/q_body - - $ref: ../swagger.yaml#/parameters/q_header - $ref: ../swagger.yaml#/parameters/request_id_header - name: x-koha-embed in: header @@ -410,7 +409,6 @@ - $ref: ../swagger.yaml#/parameters/per_page - $ref: ../swagger.yaml#/parameters/q_param - $ref: ../swagger.yaml#/parameters/q_body - - $ref: ../swagger.yaml#/parameters/q_header - $ref: ../swagger.yaml#/parameters/request_id_header - name: x-koha-embed in: header @@ -582,7 +580,6 @@ - $ref: ../swagger.yaml#/parameters/per_page - $ref: ../swagger.yaml#/parameters/q_param - $ref: ../swagger.yaml#/parameters/q_body - - $ref: ../swagger.yaml#/parameters/q_header - $ref: ../swagger.yaml#/parameters/request_id_header - name: x-koha-embed in: header @@ -850,7 +847,6 @@ - $ref: ../swagger.yaml#/parameters/per_page - $ref: ../swagger.yaml#/parameters/q_param - $ref: ../swagger.yaml#/parameters/q_body - - $ref: ../swagger.yaml#/parameters/q_header - $ref: ../swagger.yaml#/parameters/request_id_header - name: x-koha-embed in: header diff --git a/api/v1/swagger/paths/authorised_value_categories.yaml b/api/v1/swagger/paths/authorised_value_categories.yaml index f5f8387e4a..dc33c37847 100644 --- a/api/v1/swagger/paths/authorised_value_categories.yaml +++ b/api/v1/swagger/paths/authorised_value_categories.yaml @@ -25,7 +25,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" responses: 200: description: A list of authorised value categories diff --git a/api/v1/swagger/paths/authorised_values.yaml b/api/v1/swagger/paths/authorised_values.yaml index 298f3ec229..07e298dc21 100644 --- a/api/v1/swagger/paths/authorised_values.yaml +++ b/api/v1/swagger/paths/authorised_values.yaml @@ -50,7 +50,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" responses: 200: description: A list of authorised values diff --git a/api/v1/swagger/paths/authorities.yaml b/api/v1/swagger/paths/authorities.yaml index 2de38a5a36..17fb83ece6 100644 --- a/api/v1/swagger/paths/authorities.yaml +++ b/api/v1/swagger/paths/authorities.yaml @@ -13,7 +13,6 @@ - $ref: "../swagger.yaml#/parameters/order_by" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" produces: - application/json diff --git a/api/v1/swagger/paths/biblios.yaml b/api/v1/swagger/paths/biblios.yaml index fa98f152a5..93deb16e31 100644 --- a/api/v1/swagger/paths/biblios.yaml +++ b/api/v1/swagger/paths/biblios.yaml @@ -73,7 +73,6 @@ - $ref: "../swagger.yaml#/parameters/order_by" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" produces: - application/json @@ -290,7 +289,6 @@ - $ref: "../swagger.yaml#/parameters/order_by" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" - name: x-koha-embed in: header @@ -354,7 +352,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" consumes: - application/json @@ -532,7 +529,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" consumes: - application/json produces: @@ -636,7 +632,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - name: x-koha-embed in: header required: false diff --git a/api/v1/swagger/paths/biblios_item_groups.yaml b/api/v1/swagger/paths/biblios_item_groups.yaml index 0e44049dd6..7491220fb9 100644 --- a/api/v1/swagger/paths/biblios_item_groups.yaml +++ b/api/v1/swagger/paths/biblios_item_groups.yaml @@ -28,7 +28,6 @@ - "$ref": "../swagger.yaml#/parameters/per_page" - "$ref": "../swagger.yaml#/parameters/q_param" - "$ref": "../swagger.yaml#/parameters/q_body" - - "$ref": "../swagger.yaml#/parameters/q_header" produces: - application/yaml responses: diff --git a/api/v1/swagger/paths/cash_registers.yaml b/api/v1/swagger/paths/cash_registers.yaml index 719a932e8e..632fa2274f 100644 --- a/api/v1/swagger/paths/cash_registers.yaml +++ b/api/v1/swagger/paths/cash_registers.yaml @@ -16,7 +16,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" - name: x-koha-embed in: header diff --git a/api/v1/swagger/paths/checkouts.yaml b/api/v1/swagger/paths/checkouts.yaml index afe6e5660c..07aec90dc7 100644 --- a/api/v1/swagger/paths/checkouts.yaml +++ b/api/v1/swagger/paths/checkouts.yaml @@ -14,7 +14,6 @@ - $ref: "../swagger.yaml#/parameters/order_by" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" - name: checked_in in: query diff --git a/api/v1/swagger/paths/cities.yaml b/api/v1/swagger/paths/cities.yaml index c8f29ef663..b7e43a3281 100644 --- a/api/v1/swagger/paths/cities.yaml +++ b/api/v1/swagger/paths/cities.yaml @@ -35,7 +35,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" responses: "200": diff --git a/api/v1/swagger/paths/config_smtp_servers.yaml b/api/v1/swagger/paths/config_smtp_servers.yaml index effe1d8642..e07458a9a8 100644 --- a/api/v1/swagger/paths/config_smtp_servers.yaml +++ b/api/v1/swagger/paths/config_smtp_servers.yaml @@ -15,7 +15,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" responses: "200": diff --git a/api/v1/swagger/paths/erm_agreements.yaml b/api/v1/swagger/paths/erm_agreements.yaml index 289bc36a13..e54f47823f 100644 --- a/api/v1/swagger/paths/erm_agreements.yaml +++ b/api/v1/swagger/paths/erm_agreements.yaml @@ -76,7 +76,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" responses: 200: description: A list of agreement diff --git a/api/v1/swagger/paths/erm_eholdings_packages.yaml b/api/v1/swagger/paths/erm_eholdings_packages.yaml index 51899e3316..32cb417240 100644 --- a/api/v1/swagger/paths/erm_eholdings_packages.yaml +++ b/api/v1/swagger/paths/erm_eholdings_packages.yaml @@ -60,7 +60,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - name: x-koha-embed in: header required: false diff --git a/api/v1/swagger/paths/erm_eholdings_packages_resources.yaml b/api/v1/swagger/paths/erm_eholdings_packages_resources.yaml index 696f495857..8b8145d5a9 100644 --- a/api/v1/swagger/paths/erm_eholdings_packages_resources.yaml +++ b/api/v1/swagger/paths/erm_eholdings_packages_resources.yaml @@ -41,7 +41,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - name: x-koha-embed in: header required: false diff --git a/api/v1/swagger/paths/erm_eholdings_resources.yaml b/api/v1/swagger/paths/erm_eholdings_resources.yaml index a824ed6491..f5753b200f 100644 --- a/api/v1/swagger/paths/erm_eholdings_resources.yaml +++ b/api/v1/swagger/paths/erm_eholdings_resources.yaml @@ -50,7 +50,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" responses: 200: description: A list of eHoldings resources diff --git a/api/v1/swagger/paths/erm_eholdings_titles.yaml b/api/v1/swagger/paths/erm_eholdings_titles.yaml index 152fb7f8ce..6fcc1f0802 100644 --- a/api/v1/swagger/paths/erm_eholdings_titles.yaml +++ b/api/v1/swagger/paths/erm_eholdings_titles.yaml @@ -160,7 +160,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" responses: 200: description: A list of eHoldings titles diff --git a/api/v1/swagger/paths/erm_eholdings_titles_resources.yaml b/api/v1/swagger/paths/erm_eholdings_titles_resources.yaml index d5ce1e62d0..3ea8f46a63 100644 --- a/api/v1/swagger/paths/erm_eholdings_titles_resources.yaml +++ b/api/v1/swagger/paths/erm_eholdings_titles_resources.yaml @@ -41,7 +41,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - name: x-koha-embed in: header required: false diff --git a/api/v1/swagger/paths/erm_licenses.yaml b/api/v1/swagger/paths/erm_licenses.yaml index 97a6752798..3fe54fe311 100644 --- a/api/v1/swagger/paths/erm_licenses.yaml +++ b/api/v1/swagger/paths/erm_licenses.yaml @@ -50,7 +50,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - name: x-koha-embed in: header required: false diff --git a/api/v1/swagger/paths/erm_users.yaml b/api/v1/swagger/paths/erm_users.yaml index 8d9bb05023..313fd6f05d 100644 --- a/api/v1/swagger/paths/erm_users.yaml +++ b/api/v1/swagger/paths/erm_users.yaml @@ -14,7 +14,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - name: x-koha-embed in: header required: false diff --git a/api/v1/swagger/paths/holds.yaml b/api/v1/swagger/paths/holds.yaml index f63ce0c017..528656748b 100644 --- a/api/v1/swagger/paths/holds.yaml +++ b/api/v1/swagger/paths/holds.yaml @@ -87,7 +87,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" produces: - application/json @@ -591,7 +590,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" produces: - application/json diff --git a/api/v1/swagger/paths/ill_requests.yaml b/api/v1/swagger/paths/ill_requests.yaml index 3ba3f2ca3c..34ec2a289d 100644 --- a/api/v1/swagger/paths/ill_requests.yaml +++ b/api/v1/swagger/paths/ill_requests.yaml @@ -13,7 +13,6 @@ - $ref: "../swagger.yaml#/parameters/order_by" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" - name: x-koha-embed in: header diff --git a/api/v1/swagger/paths/import_batch_profiles.yaml b/api/v1/swagger/paths/import_batch_profiles.yaml index d5b9ea1b29..958b486de6 100644 --- a/api/v1/swagger/paths/import_batch_profiles.yaml +++ b/api/v1/swagger/paths/import_batch_profiles.yaml @@ -18,7 +18,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" consumes: - application/json diff --git a/api/v1/swagger/paths/items.yaml b/api/v1/swagger/paths/items.yaml index ac8c313a14..01b8d795d5 100644 --- a/api/v1/swagger/paths/items.yaml +++ b/api/v1/swagger/paths/items.yaml @@ -28,7 +28,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" consumes: - application/json @@ -240,7 +239,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - name: x-koha-embed in: header required: false @@ -353,7 +351,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" consumes: - application/json @@ -415,7 +412,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" - name: x-koha-embed in: header diff --git a/api/v1/swagger/paths/jobs.yaml b/api/v1/swagger/paths/jobs.yaml index 62ae157dc0..8fe7e04841 100644 --- a/api/v1/swagger/paths/jobs.yaml +++ b/api/v1/swagger/paths/jobs.yaml @@ -20,7 +20,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" responses: "200": diff --git a/api/v1/swagger/paths/libraries.yaml b/api/v1/swagger/paths/libraries.yaml index 045f884a6d..af452c5907 100644 --- a/api/v1/swagger/paths/libraries.yaml +++ b/api/v1/swagger/paths/libraries.yaml @@ -93,7 +93,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" - name: x-koha-embed in: header @@ -319,7 +318,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" produces: - application/json diff --git a/api/v1/swagger/paths/patrons.yaml b/api/v1/swagger/paths/patrons.yaml index 1100a9fba9..accd6651ca 100644 --- a/api/v1/swagger/paths/patrons.yaml +++ b/api/v1/swagger/paths/patrons.yaml @@ -345,7 +345,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" - name: x-koha-embed in: header diff --git a/api/v1/swagger/paths/patrons_account.yaml b/api/v1/swagger/paths/patrons_account.yaml index d67cfb55bb..1a282ab1cf 100644 --- a/api/v1/swagger/paths/patrons_account.yaml +++ b/api/v1/swagger/paths/patrons_account.yaml @@ -60,7 +60,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" responses: "200": description: A list of credits @@ -149,7 +148,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" responses: "200": description: A list of debits diff --git a/api/v1/swagger/paths/patrons_extended_attributes.yaml b/api/v1/swagger/paths/patrons_extended_attributes.yaml index 1b29f68a36..3d0ffc561c 100644 --- a/api/v1/swagger/paths/patrons_extended_attributes.yaml +++ b/api/v1/swagger/paths/patrons_extended_attributes.yaml @@ -14,7 +14,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" produces: - application/json diff --git a/api/v1/swagger/paths/patrons_holds.yaml b/api/v1/swagger/paths/patrons_holds.yaml index 1284c53607..ad13a2af5c 100644 --- a/api/v1/swagger/paths/patrons_holds.yaml +++ b/api/v1/swagger/paths/patrons_holds.yaml @@ -14,7 +14,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" produces: - application/json diff --git a/api/v1/swagger/paths/quotes.yaml b/api/v1/swagger/paths/quotes.yaml index b8646e52ea..901b7af933 100644 --- a/api/v1/swagger/paths/quotes.yaml +++ b/api/v1/swagger/paths/quotes.yaml @@ -35,7 +35,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" responses: "200": diff --git a/api/v1/swagger/paths/search_filters.yaml b/api/v1/swagger/paths/search_filters.yaml index 03de8188d6..3e388542ba 100644 --- a/api/v1/swagger/paths/search_filters.yaml +++ b/api/v1/swagger/paths/search_filters.yaml @@ -15,7 +15,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" responses: '200': diff --git a/api/v1/swagger/paths/suggestions.yaml b/api/v1/swagger/paths/suggestions.yaml index 5438188591..6e500bcf4c 100644 --- a/api/v1/swagger/paths/suggestions.yaml +++ b/api/v1/swagger/paths/suggestions.yaml @@ -14,7 +14,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" produces: - application/json @@ -246,7 +245,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - name: x-koha-embed in: header required: false diff --git a/api/v1/swagger/paths/tickets.yaml b/api/v1/swagger/paths/tickets.yaml index 709d5509b5..a0d0e2a759 100644 --- a/api/v1/swagger/paths/tickets.yaml +++ b/api/v1/swagger/paths/tickets.yaml @@ -15,7 +15,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" - name: x-koha-embed in: header @@ -228,7 +227,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" - name: x-koha-embed in: header diff --git a/api/v1/swagger/paths/transfer_limits.yaml b/api/v1/swagger/paths/transfer_limits.yaml index 5680dedbcf..253d40a1b3 100644 --- a/api/v1/swagger/paths/transfer_limits.yaml +++ b/api/v1/swagger/paths/transfer_limits.yaml @@ -33,7 +33,6 @@ - $ref: "../swagger.yaml#/parameters/per_page" - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - - $ref: "../swagger.yaml#/parameters/q_header" - $ref: "../swagger.yaml#/parameters/request_id_header" produces: - application/json diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml index 0eff0139c7..33022743f9 100644 --- a/api/v1/swagger/swagger.yaml +++ b/api/v1/swagger/swagger.yaml @@ -602,12 +602,6 @@ parameters: required: false schema: type: object - q_header: - description: Query filter sent as a request header - in: header - name: x-koha-query - required: false - type: string q_param: description: Query filter sent as a request parameter in: query @@ -718,7 +712,6 @@ info: * as a query parameter `q=` * in the request body - * in a special header `x-koha-query` For simple field equality matches we can use `{ "fieldname": "value" }` where the fieldname matches one of the fields as described in the particular endpoints response object. diff --git a/t/db_dependent/Koha/REST/Plugin/Objects.t b/t/db_dependent/Koha/REST/Plugin/Objects.t index 15076e1897..162b40f514 100755 --- a/t/db_dependent/Koha/REST/Plugin/Objects.t +++ b/t/db_dependent/Koha/REST/Plugin/Objects.t @@ -81,7 +81,6 @@ get '/biblios' => sub { my $output = $c->req->params->to_hash; $output->{query} = $c->req->json if defined $c->req->json; my $headers = $c->req->headers->to_hash; - $output->{'x-koha-query'} = $headers->{'x-koha-query'} if defined $headers->{'x-koha-query'}; $c->validation->output($output); my $biblios_set = Koha::Biblios->new; $c->stash("koha.embed", { @@ -140,7 +139,7 @@ get '/cities/:city_id/rs' => sub { }; # The tests -use Test::More tests => 18; +use Test::More tests => 17; use Test::Mojo; use t::lib::Mocks; @@ -456,30 +455,6 @@ subtest 'objects.search helper with q parameter' => sub { $schema->storage->txn_rollback; }; -subtest 'objects.search helper with x-koha-query header' => sub { - plan tests => 4; - - $schema->storage->txn_begin; - - my $patron1 = $builder->build_object( { class => "Koha::Patrons" } ); - my $patron2 = $builder->build_object( { class => "Koha::Patrons" } ); - my $biblio1 = $builder->build_sample_biblio; - my $biblio2 = $builder->build_sample_biblio; - my $biblio3 = $builder->build_sample_biblio; - my $suggestion1 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron1->borrowernumber, biblionumber => $biblio1->biblionumber} } ); - my $suggestion2 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio2->biblionumber} } ); - my $suggestion3 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio3->biblionumber} } ); - - my $t = Test::Mojo->new; - $t->get_ok('/biblios' => {'x-koha-query' => '{"suggestions.suggester.patron_id": "'.$patron1->borrowernumber.'"}'}) - ->json_is('/count' => 1, 'there should be 1 biblio with suggestions of patron 1'); - - $t->get_ok('/biblios' => {'x-koha-query' => '{"suggestions.suggester.patron_id": "'.$patron2->borrowernumber.'"}'}) - ->json_is('/count' => 2, 'there should be 2 biblios with suggestions of patron 2'); - - $schema->storage->txn_rollback; -}; - subtest 'objects.search helper with all query methods' => sub { plan tests => 6; @@ -495,14 +470,29 @@ subtest 'objects.search helper with all query methods' => sub { my $suggestion3 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio3->biblionumber} } ); my $t = Test::Mojo->new; - $t->get_ok('/biblios?q={"suggestions.suggester.firstname": "'.$patron1->firstname.'"}' => {'x-koha-query' => '{"suggestions.suggester.patron_id": "'.$patron1->borrowernumber.'"}'} => json => {"suggestions.suggester.cardnumber" => $patron1->cardnumber}) - ->json_is('/count' => 1, 'there should be 1 biblio with suggestions of patron 1'); - - $t->get_ok('/biblios?q={"suggestions.suggester.firstname": "'.$patron2->firstname.'"}' => {'x-koha-query' => '{"suggestions.suggester.patron_id": "'.$patron2->borrowernumber.'"}'} => json => {"suggestions.suggester.cardnumber" => $patron2->cardnumber}) - ->json_is('/count' => 2, 'there should be 2 biblios with suggestions of patron 2'); - - $t->get_ok('/biblios?q={"suggestions.suggester.firstname": "'.$patron1->firstname.'"}' => {'x-koha-query' => '{"suggestions.suggester.patron_id": "'.$patron2->borrowernumber.'"}'} => json => {"suggestions.suggester.cardnumber" => $patron2->cardnumber}) - ->json_is('/count' => 0, 'there shouldn\'t be biblios where suggester has patron1 fistname and patron2 id'); + my $query = { + "suggestions.suggester.firstname" => $patron1->firstname, + "suggestions.suggester.patron_id" => $patron1->id, + }; + $t->get_ok( + '/biblios?q=' . encode_json($query) => json => { "suggestions.suggester.cardnumber" => $patron1->cardnumber } ) + ->json_is( '/count' => 1, 'there should be 1 biblio with suggestions of patron 1' ); + + $query = { + "suggestions.suggester.firstname" => $patron2->firstname, + "suggestions.suggester.patron_id" => $patron2->id, + }; + $t->get_ok( + '/biblios?q=' . encode_json($query) => json => { "suggestions.suggester.cardnumber" => $patron2->cardnumber } ) + ->json_is( '/count' => 2, 'there should be 2 biblios with suggestions of patron 2' ); + + $query = { + "suggestions.suggester.firstname" => $patron1->firstname, + "suggestions.suggester.patron_id" => $patron2->id, + }; + $t->get_ok( + '/biblios?q=' . encode_json($query) => json => { "suggestions.suggester.cardnumber" => $patron2->cardnumber } ) + ->json_is( '/count' => 0, 'there shouldn\'t be biblios where suggester has patron1 fistname and patron2 id' ); $schema->storage->txn_rollback; }; -- 2.39.5