From 90642f1dafb9f1905a6ad2b019808ff7cea26603 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 20 Jul 2023 20:18:27 -0300 Subject: [PATCH] Bug 34333: Add embed option for `cancellation_requested` for holds This patch adds the `cancellation_requested` attribute to the hold object definition, and allows embeding it as on the different holds endpoints that migt be useful. To test: 1. Apply this patches 2. Run: $ kshell k$ prove t/db_dependent/Koha/Hold.t \ t/db_dependent/api/v1/*holds.t => SUCCESS: Tests pass! 3. Play with your REST tool (Postman?) on the following endpoints: GET http://localhost:8081/api/v1/holds GET http://localhost:8081/api/v1/patrons/:patron_id/holds on both, pass and not pass the `x-koha-embed` header with `cancellation_requested` on it. => SUCCESS: It is easy! You see the attribute and you don't, and the content makes sense! 4. Sign off :-D --- api/v1/swagger/definitions/hold.yaml | 6 ++++++ api/v1/swagger/paths/holds.yaml | 10 ++++++++++ api/v1/swagger/paths/patrons_holds.yaml | 10 ++++++++++ 3 files changed, 26 insertions(+) diff --git a/api/v1/swagger/definitions/hold.yaml b/api/v1/swagger/definitions/hold.yaml index a7d0d393301..f97c3e216b8 100644 --- a/api/v1/swagger/definitions/hold.yaml +++ b/api/v1/swagger/definitions/hold.yaml @@ -103,4 +103,10 @@ properties: item_level: type: boolean description: If the hold is placed at item level + cancellation_requested: + type: + - boolean + - "null" + description: Cancellation requests count for the hold (x-koha-embed) + additionalProperties: false diff --git a/api/v1/swagger/paths/holds.yaml b/api/v1/swagger/paths/holds.yaml index 528656748b4..3121c78726d 100644 --- a/api/v1/swagger/paths/holds.yaml +++ b/api/v1/swagger/paths/holds.yaml @@ -88,6 +88,16 @@ - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - $ref: "../swagger.yaml#/parameters/request_id_header" + - name: x-koha-embed + in: header + required: false + description: Embed list sent as a request header + type: array + items: + type: string + enum: + - cancellation_requested + collectionFormat: csv produces: - application/json responses: diff --git a/api/v1/swagger/paths/patrons_holds.yaml b/api/v1/swagger/paths/patrons_holds.yaml index ad13a2af5cc..e8e1335a87d 100644 --- a/api/v1/swagger/paths/patrons_holds.yaml +++ b/api/v1/swagger/paths/patrons_holds.yaml @@ -15,6 +15,16 @@ - $ref: "../swagger.yaml#/parameters/q_param" - $ref: "../swagger.yaml#/parameters/q_body" - $ref: "../swagger.yaml#/parameters/request_id_header" + - name: x-koha-embed + in: header + required: false + description: Embed list sent as a request header + type: array + items: + type: string + enum: + - cancellation_requested + collectionFormat: csv produces: - application/json responses: -- 2.41.0