From c95512ed7b93b269258ed6e6689a335758dbb1f2 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 30 Mar 2022 13:54:24 +0200 Subject: [PATCH] Bug 30394: Add x-koha-request-id support on API routes This patch adds the x-koha-request-id to all GET routes that rely on objects.search, for immediate support for the header. The patch itself is trivial: - It adds the header parameter definition to the top level swagger.yaml - It adds a reference on each route that already implements q params, etc To test: 1. Apply the patch 2. Reload plack 3. Notice the API still works 4. Run: $ kshell k$ prove t/db_dependent/api/v1/query.t => SUCCESS: It now passes! The /cities route implements the x-koha-request-id header pass through. 5. Run the rest of the API tests => SUCCESS: All good 6. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- api/v1/swagger/paths/acquisitions_funds.yaml | 1 + api/v1/swagger/paths/acquisitions_orders.yaml | 1 + api/v1/swagger/paths/acquisitions_vendors.yaml | 1 + api/v1/swagger/paths/advancededitormacros.yaml | 1 + api/v1/swagger/paths/biblios.yaml | 2 ++ 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/holds.yaml | 2 ++ api/v1/swagger/paths/import_batch_profiles.yaml | 1 + api/v1/swagger/paths/items.yaml | 2 ++ api/v1/swagger/paths/libraries.yaml | 2 ++ api/v1/swagger/paths/patrons.yaml | 1 + api/v1/swagger/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/suggestions.yaml | 1 + api/v1/swagger/paths/transfer_limits.yaml | 1 + api/v1/swagger/swagger.yaml | 6 ++++++ 20 files changed, 29 insertions(+) diff --git a/api/v1/swagger/paths/acquisitions_funds.yaml b/api/v1/swagger/paths/acquisitions_funds.yaml index 492d6eb05d6..309c50b38f6 100644 --- a/api/v1/swagger/paths/acquisitions_funds.yaml +++ b/api/v1/swagger/paths/acquisitions_funds.yaml @@ -26,6 +26,7 @@ - $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": description: A list of funds diff --git a/api/v1/swagger/paths/acquisitions_orders.yaml b/api/v1/swagger/paths/acquisitions_orders.yaml index 46727236c9c..cc8411d0bab 100644 --- a/api/v1/swagger/paths/acquisitions_orders.yaml +++ b/api/v1/swagger/paths/acquisitions_orders.yaml @@ -42,6 +42,7 @@ - $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": description: A list of orders diff --git a/api/v1/swagger/paths/acquisitions_vendors.yaml b/api/v1/swagger/paths/acquisitions_vendors.yaml index bb7050af517..f5275ddfe1b 100644 --- a/api/v1/swagger/paths/acquisitions_vendors.yaml +++ b/api/v1/swagger/paths/acquisitions_vendors.yaml @@ -26,6 +26,7 @@ - $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": description: A list of vendors diff --git a/api/v1/swagger/paths/advancededitormacros.yaml b/api/v1/swagger/paths/advancededitormacros.yaml index edd354d2bc9..0cb4c343230 100644 --- a/api/v1/swagger/paths/advancededitormacros.yaml +++ b/api/v1/swagger/paths/advancededitormacros.yaml @@ -36,6 +36,7 @@ - $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": description: A list of macros diff --git a/api/v1/swagger/paths/biblios.yaml b/api/v1/swagger/paths/biblios.yaml index cddb61c49a4..65b2033c8fe 100644 --- a/api/v1/swagger/paths/biblios.yaml +++ b/api/v1/swagger/paths/biblios.yaml @@ -108,6 +108,7 @@ - $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 description: By default, current checkouts are returned, when this is true then @@ -163,6 +164,7 @@ - $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 produces: diff --git a/api/v1/swagger/paths/cash_registers.yaml b/api/v1/swagger/paths/cash_registers.yaml index 63d433888f1..56ca1b8aea8 100644 --- a/api/v1/swagger/paths/cash_registers.yaml +++ b/api/v1/swagger/paths/cash_registers.yaml @@ -17,6 +17,7 @@ - $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": description: Cashups performed on this register diff --git a/api/v1/swagger/paths/checkouts.yaml b/api/v1/swagger/paths/checkouts.yaml index 4bd92218262..e8ff04e335c 100644 --- a/api/v1/swagger/paths/checkouts.yaml +++ b/api/v1/swagger/paths/checkouts.yaml @@ -15,6 +15,7 @@ - $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 description: By default, current checkouts are returned, when this is true then diff --git a/api/v1/swagger/paths/cities.yaml b/api/v1/swagger/paths/cities.yaml index b8a3277bbf5..c8f29ef663d 100644 --- a/api/v1/swagger/paths/cities.yaml +++ b/api/v1/swagger/paths/cities.yaml @@ -36,6 +36,7 @@ - $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": description: A list of cities diff --git a/api/v1/swagger/paths/config_smtp_servers.yaml b/api/v1/swagger/paths/config_smtp_servers.yaml index f2e71eb14f5..effe1d8642e 100644 --- a/api/v1/swagger/paths/config_smtp_servers.yaml +++ b/api/v1/swagger/paths/config_smtp_servers.yaml @@ -16,6 +16,7 @@ - $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": description: A list of SMTP servers diff --git a/api/v1/swagger/paths/holds.yaml b/api/v1/swagger/paths/holds.yaml index b42326fa3e2..a598c7a90d7 100644 --- a/api/v1/swagger/paths/holds.yaml +++ b/api/v1/swagger/paths/holds.yaml @@ -84,6 +84,7 @@ - $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 responses: @@ -572,6 +573,7 @@ - $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 responses: diff --git a/api/v1/swagger/paths/import_batch_profiles.yaml b/api/v1/swagger/paths/import_batch_profiles.yaml index bae3bb51c5e..d5b9ea1b29f 100644 --- a/api/v1/swagger/paths/import_batch_profiles.yaml +++ b/api/v1/swagger/paths/import_batch_profiles.yaml @@ -19,6 +19,7 @@ - $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 produces: diff --git a/api/v1/swagger/paths/items.yaml b/api/v1/swagger/paths/items.yaml index 806d777b90c..66fc1ee6a8a 100644 --- a/api/v1/swagger/paths/items.yaml +++ b/api/v1/swagger/paths/items.yaml @@ -19,6 +19,7 @@ - $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 produces: @@ -113,6 +114,7 @@ - $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 produces: diff --git a/api/v1/swagger/paths/libraries.yaml b/api/v1/swagger/paths/libraries.yaml index 754f87bf072..3552f8f6fe0 100644 --- a/api/v1/swagger/paths/libraries.yaml +++ b/api/v1/swagger/paths/libraries.yaml @@ -99,6 +99,7 @@ - $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 responses: @@ -308,6 +309,7 @@ - $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 responses: diff --git a/api/v1/swagger/paths/patrons.yaml b/api/v1/swagger/paths/patrons.yaml index fcef92d25d4..9519bc1928e 100644 --- a/api/v1/swagger/paths/patrons.yaml +++ b/api/v1/swagger/paths/patrons.yaml @@ -351,6 +351,7 @@ - $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": description: A list of patrons diff --git a/api/v1/swagger/paths/patrons_extended_attributes.yaml b/api/v1/swagger/paths/patrons_extended_attributes.yaml index ac9e2aea666..1b29f68a364 100644 --- a/api/v1/swagger/paths/patrons_extended_attributes.yaml +++ b/api/v1/swagger/paths/patrons_extended_attributes.yaml @@ -15,6 +15,7 @@ - $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 responses: diff --git a/api/v1/swagger/paths/patrons_holds.yaml b/api/v1/swagger/paths/patrons_holds.yaml index b2df8664d78..1284c536071 100644 --- a/api/v1/swagger/paths/patrons_holds.yaml +++ b/api/v1/swagger/paths/patrons_holds.yaml @@ -15,6 +15,7 @@ - $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 responses: diff --git a/api/v1/swagger/paths/quotes.yaml b/api/v1/swagger/paths/quotes.yaml index 15ea79eebfa..b8646e52eac 100644 --- a/api/v1/swagger/paths/quotes.yaml +++ b/api/v1/swagger/paths/quotes.yaml @@ -36,6 +36,7 @@ - $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": description: A list of quotes diff --git a/api/v1/swagger/paths/suggestions.yaml b/api/v1/swagger/paths/suggestions.yaml index ed29237d273..ecf46837d07 100644 --- a/api/v1/swagger/paths/suggestions.yaml +++ b/api/v1/swagger/paths/suggestions.yaml @@ -15,6 +15,7 @@ - $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 responses: diff --git a/api/v1/swagger/paths/transfer_limits.yaml b/api/v1/swagger/paths/transfer_limits.yaml index f34a423841e..5680dedbcfb 100644 --- a/api/v1/swagger/paths/transfer_limits.yaml +++ b/api/v1/swagger/paths/transfer_limits.yaml @@ -34,6 +34,7 @@ - $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 responses: diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml index b724868c0cb..0af9371cf84 100644 --- a/api/v1/swagger/swagger.yaml +++ b/api/v1/swagger/swagger.yaml @@ -365,6 +365,12 @@ parameters: name: quote_id required: true type: integer + request_id_header: + description: Request id header + in: header + name: x-koha-request-id + required: false + type: integer seen_pp: description: Item was seen flag in: query -- 2.25.1