From 709e57ece97b507f4c0a7e613adcc652acf57e27 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 8 Jul 2024 17:21:25 -0300 Subject: [PATCH] [23.05.x] Bug 37018: Add 400 response definition to all routes This patch adds a test for well defined 400 responses on all verbs and paths on the API spec. The tests verify: * Presence of 400 response definition * The description must start with 'Bad request' (needs coding guideline) * If DBIC queries are allowed on the route, then `invalid_query` needs to be mentioned in the description. All routes get fixed to make the tests pass. To test: 1. Apply this patch 2. Run: $ ktd --shell k$ yarn api:bundle k$ prove xt/api.t => SUCCESS: Tests pass! Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- Koha/REST/Plugin/Exceptions.pm | 2 +- .../swagger/paths/acquisitions_baskets.yaml | 7 ++ api/v1/swagger/paths/acquisitions_funds.yaml | 21 +++++ api/v1/swagger/paths/acquisitions_orders.yaml | 19 +++++ .../swagger/paths/acquisitions_vendors.yaml | 23 ++++++ .../swagger/paths/advancededitormacros.yaml | 39 +++++++++ api/v1/swagger/paths/auth.yaml | 82 +++++++++++++++---- .../paths/authorised_value_categories.yaml | 5 +- api/v1/swagger/paths/authorised_values.yaml | 5 +- api/v1/swagger/paths/authorities.yaml | 17 +++- api/v1/swagger/paths/biblios.yaml | 49 ++++++++++- api/v1/swagger/paths/biblios_item_groups.yaml | 19 ++++- api/v1/swagger/paths/cash_registers.yaml | 11 +++ api/v1/swagger/paths/checkouts.yaml | 27 ++++++ api/v1/swagger/paths/circulation-rules.yaml | 4 + api/v1/swagger/paths/cities.yaml | 23 ++++++ api/v1/swagger/paths/clubs.yaml | 2 +- api/v1/swagger/paths/config_smtp_servers.yaml | 23 ++++++ api/v1/swagger/paths/erm_agreements.yaml | 17 ++-- api/v1/swagger/paths/erm_config.yaml | 5 +- api/v1/swagger/paths/erm_documents.yaml | 4 + .../swagger/paths/erm_eholdings_packages.yaml | 21 +++-- .../erm_eholdings_packages_resources.yaml | 7 +- .../paths/erm_eholdings_resources.yaml | 15 +++- .../swagger/paths/erm_eholdings_titles.yaml | 19 +++-- .../paths/erm_eholdings_titles_resources.yaml | 7 +- api/v1/swagger/paths/erm_licenses.yaml | 17 ++-- api/v1/swagger/paths/erm_users.yaml | 7 +- api/v1/swagger/paths/holds.yaml | 32 ++++++-- api/v1/swagger/paths/ill_backends.yaml | 10 ++- api/v1/swagger/paths/ill_requests.yaml | 7 ++ .../swagger/paths/import_batch_profiles.yaml | 15 +++- api/v1/swagger/paths/import_batches.yaml | 6 +- api/v1/swagger/paths/item_types.yaml | 7 +- api/v1/swagger/paths/items.yaml | 34 ++++++-- api/v1/swagger/paths/jobs.yaml | 11 +++ api/v1/swagger/paths/libraries.yaml | 26 ++++++ api/v1/swagger/paths/oauth.yaml | 4 +- api/v1/swagger/paths/patrons.yaml | 29 ++++++- api/v1/swagger/paths/patrons_account.yaml | 24 +++++- .../paths/patrons_extended_attributes.yaml | 17 +++- api/v1/swagger/paths/patrons_holds.yaml | 7 ++ api/v1/swagger/paths/public_oauth.yaml | 7 +- api/v1/swagger/paths/quotes.yaml | 23 ++++++ api/v1/swagger/paths/rotas.yaml | 5 +- api/v1/swagger/paths/search_filters.yaml | 23 ++++++ api/v1/swagger/paths/suggestions.yaml | 22 +++++ api/v1/swagger/paths/tickets.yaml | 41 ++++++++++ api/v1/swagger/paths/transfer_limits.yaml | 13 ++- t/db_dependent/api/v1/query.t | 2 +- xt/api.t | 46 ++++++++++- 51 files changed, 822 insertions(+), 86 deletions(-) diff --git a/Koha/REST/Plugin/Exceptions.pm b/Koha/REST/Plugin/Exceptions.pm index 22f0b314430..5107af103d5 100644 --- a/Koha/REST/Plugin/Exceptions.pm +++ b/Koha/REST/Plugin/Exceptions.pm @@ -61,7 +61,7 @@ sub register { if ( blessed $exception && ref($exception) eq 'Koha::Exceptions::REST::Query::InvalidOperator' ) { return $c->render( - status => 500, + status => 400, json => { error => printf( "Invalid operator in query: %s", $exception->operator ), error_code => 'invalid_query', diff --git a/api/v1/swagger/paths/acquisitions_baskets.yaml b/api/v1/swagger/paths/acquisitions_baskets.yaml index 89b7d7e42b0..7dd594750a1 100644 --- a/api/v1/swagger/paths/acquisitions_baskets.yaml +++ b/api/v1/swagger/paths/acquisitions_baskets.yaml @@ -34,6 +34,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/patron" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: diff --git a/api/v1/swagger/paths/acquisitions_funds.yaml b/api/v1/swagger/paths/acquisitions_funds.yaml index 31f0455e5be..eb76fac6ffb 100644 --- a/api/v1/swagger/paths/acquisitions_funds.yaml +++ b/api/v1/swagger/paths/acquisitions_funds.yaml @@ -34,6 +34,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/fund" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -95,6 +102,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/patron" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -148,6 +162,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/patron" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: diff --git a/api/v1/swagger/paths/acquisitions_orders.yaml b/api/v1/swagger/paths/acquisitions_orders.yaml index bebe27e4026..7fe11327a15 100644 --- a/api/v1/swagger/paths/acquisitions_orders.yaml +++ b/api/v1/swagger/paths/acquisitions_orders.yaml @@ -75,6 +75,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/order" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -192,6 +199,10 @@ description: An order schema: $ref: "../swagger.yaml#/definitions/order" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -239,6 +250,10 @@ description: An order schema: $ref: "../swagger.yaml#/definitions/order" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -278,6 +293,10 @@ responses: "204": description: Order deleted + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/acquisitions_vendors.yaml b/api/v1/swagger/paths/acquisitions_vendors.yaml index 599b213cb09..d87c199b841 100644 --- a/api/v1/swagger/paths/acquisitions_vendors.yaml +++ b/api/v1/swagger/paths/acquisitions_vendors.yaml @@ -44,6 +44,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/vendor" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -90,6 +97,10 @@ description: Vendor added schema: $ref: "../swagger.yaml#/definitions/vendor" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -132,6 +143,10 @@ description: A vendor schema: $ref: "../swagger.yaml#/definitions/vendor" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -179,6 +194,10 @@ description: A vendor schema: $ref: "../swagger.yaml#/definitions/vendor" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -218,6 +237,10 @@ responses: "204": description: Vendor deleted + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/advancededitormacros.yaml b/api/v1/swagger/paths/advancededitormacros.yaml index 0cb4c343230..40f5615ba01 100644 --- a/api/v1/swagger/paths/advancededitormacros.yaml +++ b/api/v1/swagger/paths/advancededitormacros.yaml @@ -44,6 +44,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/advancededitormacro" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -82,6 +89,10 @@ description: Macro added schema: $ref: "../swagger.yaml#/definitions/advancededitormacro" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -122,6 +133,10 @@ description: Macro added schema: $ref: "../swagger.yaml#/definitions/advancededitormacro" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -159,6 +174,10 @@ description: A macro schema: $ref: "../swagger.yaml#/definitions/advancededitormacro" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -199,6 +218,10 @@ description: An advanced editor macro schema: $ref: "../swagger.yaml#/definitions/advancededitormacro" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -237,6 +260,10 @@ description: Advanced editor macro deleted schema: type: string + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -276,6 +303,10 @@ description: A macro schema: $ref: "../swagger.yaml#/definitions/advancededitormacro" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -316,6 +347,10 @@ description: An advanced editor macro schema: $ref: "../swagger.yaml#/definitions/advancededitormacro" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -356,6 +391,10 @@ description: Advanced editor macro deleted schema: type: string + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/auth.yaml b/api/v1/swagger/paths/auth.yaml index b893db9d912..1c28ebe0c75 100644 --- a/api/v1/swagger/paths/auth.yaml +++ b/api/v1/swagger/paths/auth.yaml @@ -22,7 +22,7 @@ type: integer additionalProperties: false "400": - description: Bad Request + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "403": @@ -65,7 +65,7 @@ type: string additionalProperties: false "400": - description: Bad Request + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "403": @@ -111,7 +111,7 @@ schema: $ref: "../swagger.yaml#/definitions/error" "400": - description: Bad Request + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "403": @@ -164,9 +164,12 @@ items: $ref: ../swagger.yaml#/definitions/auth_provider "400": - description: Bad Request + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: - $ref: ../swagger.yaml#/definitions/error + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -226,7 +229,7 @@ schema: $ref: ../swagger.yaml#/definitions/auth_provider "400": - description: Bad Request + description: Bad request schema: $ref: ../swagger.yaml#/definitions/error "403": @@ -273,6 +276,10 @@ description: An identity provider schema: $ref: ../swagger.yaml#/definitions/auth_provider + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "404": description: Object not found schema: @@ -333,7 +340,7 @@ schema: $ref: ../swagger.yaml#/definitions/auth_provider "400": - description: Bad Request + description: Bad request schema: $ref: ../swagger.yaml#/definitions/error "403": @@ -371,6 +378,10 @@ responses: "204": description: identity provider deleted + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -430,6 +441,13 @@ schema: items: $ref: ../swagger.yaml#/definitions/auth_provider_domain + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "404": description: Object not found schema: @@ -470,7 +488,7 @@ schema: $ref: ../swagger.yaml#/definitions/auth_provider_domain "400": - description: Bad Request + description: Bad request schema: $ref: ../swagger.yaml#/definitions/error "403": @@ -512,6 +530,10 @@ description: An identity provider schema: $ref: ../swagger.yaml#/definitions/auth_provider_domain + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "404": description: Object not found schema: @@ -544,6 +566,10 @@ responses: "204": description: identity provider deleted + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -604,9 +630,12 @@ items: $ref: ../swagger.yaml#/definitions/identity_provider "400": - description: Bad Request + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: - $ref: ../swagger.yaml#/definitions/error + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -666,7 +695,7 @@ schema: $ref: ../swagger.yaml#/definitions/identity_provider "400": - description: Bad Request + description: Bad request schema: $ref: ../swagger.yaml#/definitions/error "403": @@ -713,6 +742,10 @@ description: An identity provider schema: $ref: ../swagger.yaml#/definitions/identity_provider + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "404": description: Object not found schema: @@ -773,7 +806,7 @@ schema: $ref: ../swagger.yaml#/definitions/identity_provider "400": - description: Bad Request + description: Bad request schema: $ref: ../swagger.yaml#/definitions/error "403": @@ -810,7 +843,11 @@ - application/json responses: "204": - description: identity provider deleted + description: Identity provider deleted + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -870,6 +907,13 @@ schema: items: $ref: ../swagger.yaml#/definitions/identity_provider_domain + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "404": description: Object not found schema: @@ -910,7 +954,7 @@ schema: $ref: ../swagger.yaml#/definitions/identity_provider_domain "400": - description: Bad Request + description: Bad request schema: $ref: ../swagger.yaml#/definitions/error "403": @@ -952,6 +996,10 @@ description: An identity provider schema: $ref: ../swagger.yaml#/definitions/identity_provider_domain + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "404": description: Object not found schema: @@ -993,7 +1041,7 @@ schema: $ref: ../swagger.yaml#/definitions/identity_provider_domain "400": - description: Bad Request + description: Bad request schema: $ref: ../swagger.yaml#/definitions/error "403": @@ -1032,6 +1080,10 @@ responses: "204": description: identity provider deleted + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/authorised_value_categories.yaml b/api/v1/swagger/paths/authorised_value_categories.yaml index f5f8387e4ab..1806e29e572 100644 --- a/api/v1/swagger/paths/authorised_value_categories.yaml +++ b/api/v1/swagger/paths/authorised_value_categories.yaml @@ -34,7 +34,10 @@ $ref: "../swagger.yaml#/definitions/authorised_value_category" type: array 400: - description: Bad request + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" 403: diff --git a/api/v1/swagger/paths/authorised_values.yaml b/api/v1/swagger/paths/authorised_values.yaml index 298f3ec2294..53bac0726fe 100644 --- a/api/v1/swagger/paths/authorised_values.yaml +++ b/api/v1/swagger/paths/authorised_values.yaml @@ -59,7 +59,10 @@ $ref: "../swagger.yaml#/definitions/authorised_value" type: array 400: - description: Bad request + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" 403: diff --git a/api/v1/swagger/paths/authorities.yaml b/api/v1/swagger/paths/authorities.yaml index 2de38a5a36b..d73b041be0d 100644 --- a/api/v1/swagger/paths/authorities.yaml +++ b/api/v1/swagger/paths/authorities.yaml @@ -24,6 +24,13 @@ responses: "200": description: A list of authorities + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -92,7 +99,7 @@ "201": description: An authority "400": - description: Bad request. + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -149,6 +156,10 @@ responses: "200": description: An authority + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -197,6 +208,10 @@ description: Authority deleted schema: type: string + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/biblios.yaml b/api/v1/swagger/paths/biblios.yaml index 5b58c3c9c6e..abdec378350 100644 --- a/api/v1/swagger/paths/biblios.yaml +++ b/api/v1/swagger/paths/biblios.yaml @@ -84,6 +84,13 @@ responses: "200": description: A list of biblios + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -135,6 +142,10 @@ responses: "200": description: A biblio + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -183,6 +194,10 @@ description: Biblio deleted schema: type: string + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -317,6 +332,13 @@ description: A list of checkouts schema: $ref: "../swagger.yaml#/definitions/checkouts" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -377,6 +399,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/item" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -555,7 +584,10 @@ items: $ref: "../swagger.yaml#/definitions/library" "400": - description: Missing or wrong parameters + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -601,6 +633,10 @@ responses: "200": description: A biblio + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -668,6 +704,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/item" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -741,6 +784,10 @@ description: number of ratings type: integer additionalProperties: false + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/biblios_item_groups.yaml b/api/v1/swagger/paths/biblios_item_groups.yaml index 0e44049dd6b..b6a098cfb6d 100644 --- a/api/v1/swagger/paths/biblios_item_groups.yaml +++ b/api/v1/swagger/paths/biblios_item_groups.yaml @@ -38,6 +38,13 @@ type: array items: "$ref": "../swagger.yaml#/definitions/item_group" + '400': + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" '401': description: Authentication required schema: @@ -91,7 +98,7 @@ schema: "$ref": "../swagger.yaml#/definitions/item_group" '400': - description: Bad parameter + description: Bad request schema: "$ref": "../swagger.yaml#/definitions/error" '401': @@ -157,7 +164,7 @@ schema: "$ref": "../swagger.yaml#/definitions/item_group" '400': - description: Missing or wrong parameters + description: Bad request schema: "$ref": "../swagger.yaml#/definitions/error" '404': @@ -274,6 +281,10 @@ description: ItemGroup deleted schema: type: string + '400': + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" '401': description: Authentication required schema: @@ -398,6 +409,10 @@ description: Item unlinked from item group schema: type: string + '400': + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" '401': description: Authentication required schema: diff --git a/api/v1/swagger/paths/cash_registers.yaml b/api/v1/swagger/paths/cash_registers.yaml index 719a932e8e8..82372b8335d 100644 --- a/api/v1/swagger/paths/cash_registers.yaml +++ b/api/v1/swagger/paths/cash_registers.yaml @@ -35,6 +35,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/cashup" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -83,6 +90,10 @@ description: A cashup schema: $ref: "../swagger.yaml#/definitions/cashup" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: diff --git a/api/v1/swagger/paths/checkouts.yaml b/api/v1/swagger/paths/checkouts.yaml index d20aaa1f7de..758a899b9fd 100644 --- a/api/v1/swagger/paths/checkouts.yaml +++ b/api/v1/swagger/paths/checkouts.yaml @@ -39,6 +39,13 @@ description: A list of checkouts schema: $ref: "../swagger.yaml#/definitions/checkouts" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -88,6 +95,10 @@ description: Updated borrower's checkout schema: $ref: "../swagger.yaml#/definitions/checkout" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -127,6 +138,10 @@ description: Updated borrower's checkout schema: $ref: "../swagger.yaml#/definitions/checkout" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Cannot renew checkout schema: @@ -166,6 +181,10 @@ description: Updated borrower's checkout schema: $ref: "../swagger.yaml#/definitions/checkout" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Cannot renew checkout schema: @@ -213,6 +232,10 @@ description: List of checkouts renewals schema: $ref: "../swagger.yaml#/definitions/renewals" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -251,6 +274,10 @@ description: Checkout renewability information schema: $ref: "../swagger.yaml#/definitions/allows_renewal" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Forbidden schema: diff --git a/api/v1/swagger/paths/circulation-rules.yaml b/api/v1/swagger/paths/circulation-rules.yaml index 545f15458a9..b5f9222099d 100644 --- a/api/v1/swagger/paths/circulation-rules.yaml +++ b/api/v1/swagger/paths/circulation-rules.yaml @@ -15,6 +15,10 @@ type: object additionalProperties: $ref: "../swagger.yaml#/definitions/circ-rule-kind" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: diff --git a/api/v1/swagger/paths/cities.yaml b/api/v1/swagger/paths/cities.yaml index c8f29ef663d..a376c4dc149 100644 --- a/api/v1/swagger/paths/cities.yaml +++ b/api/v1/swagger/paths/cities.yaml @@ -44,6 +44,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/city" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -82,6 +89,10 @@ description: City added schema: $ref: "../swagger.yaml#/definitions/city" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -120,6 +131,10 @@ description: A city schema: $ref: "../swagger.yaml#/definitions/city" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "404": description: City not found schema: @@ -159,6 +174,10 @@ description: A city schema: $ref: "../swagger.yaml#/definitions/city" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -195,6 +214,10 @@ responses: "204": description: City deleted + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/clubs.yaml b/api/v1/swagger/paths/clubs.yaml index 7e09954d7c2..9d04355ee28 100644 --- a/api/v1/swagger/paths/clubs.yaml +++ b/api/v1/swagger/paths/clubs.yaml @@ -61,7 +61,7 @@ schema: $ref: "../definitions/club_hold.yaml" "400": - description: Missing or wrong parameters + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": diff --git a/api/v1/swagger/paths/config_smtp_servers.yaml b/api/v1/swagger/paths/config_smtp_servers.yaml index effe1d8642e..82428b1e533 100644 --- a/api/v1/swagger/paths/config_smtp_servers.yaml +++ b/api/v1/swagger/paths/config_smtp_servers.yaml @@ -24,6 +24,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/smtp_server" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -62,6 +69,10 @@ description: An SMTP server object schema: $ref: "../swagger.yaml#/definitions/smtp_server" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -104,6 +115,10 @@ description: An SMTP server object schema: $ref: "../swagger.yaml#/definitions/smtp_server" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "404": description: Object not found schema: @@ -147,6 +162,10 @@ description: An SMTP server object schema: $ref: "../swagger.yaml#/definitions/smtp_server" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -186,6 +205,10 @@ responses: "204": description: SMTP server deleted + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/erm_agreements.yaml b/api/v1/swagger/paths/erm_agreements.yaml index 655fed2e3a6..8e633ead711 100644 --- a/api/v1/swagger/paths/erm_agreements.yaml +++ b/api/v1/swagger/paths/erm_agreements.yaml @@ -84,8 +84,11 @@ items: $ref: "../swagger.yaml#/definitions/erm_agreement" type: array - 400: - description: Bad request + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" 403: @@ -129,7 +132,7 @@ items: $ref: "../swagger.yaml#/definitions/erm_agreement" 400: - description: Bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" 401: @@ -203,6 +206,10 @@ schema: items: $ref: "../swagger.yaml#/definitions/erm_agreement" + 400: + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" 401: description: Authentication required schema: @@ -267,7 +274,7 @@ items: $ref: "../swagger.yaml#/definitions/erm_agreement" 400: - description: Bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" 403: @@ -313,7 +320,7 @@ 204: description: Agreement deleted 400: - description: Agreement deletion failed + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" 401: diff --git a/api/v1/swagger/paths/erm_config.yaml b/api/v1/swagger/paths/erm_config.yaml index faa824d5b02..e938972d776 100644 --- a/api/v1/swagger/paths/erm_config.yaml +++ b/api/v1/swagger/paths/erm_config.yaml @@ -15,7 +15,10 @@ schema: $ref: "../swagger.yaml#/definitions/erm_config" 400: - description: Bad request + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" 403: diff --git a/api/v1/swagger/paths/erm_documents.yaml b/api/v1/swagger/paths/erm_documents.yaml index 80be3279b3c..a0b44266754 100644 --- a/api/v1/swagger/paths/erm_documents.yaml +++ b/api/v1/swagger/paths/erm_documents.yaml @@ -19,6 +19,10 @@ description: Anagreement schema: type: file + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" 401: description: Authentication required schema: diff --git a/api/v1/swagger/paths/erm_eholdings_packages.yaml b/api/v1/swagger/paths/erm_eholdings_packages.yaml index 0237e6fcfb8..31f8fdff31b 100644 --- a/api/v1/swagger/paths/erm_eholdings_packages.yaml +++ b/api/v1/swagger/paths/erm_eholdings_packages.yaml @@ -81,8 +81,11 @@ items: $ref: "../swagger.yaml#/definitions/erm_eholdings_package" type: array - 400: - description: Bad request + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" 403: @@ -131,7 +134,7 @@ items: $ref: "../swagger.yaml#/definitions/erm_eholdings_package" 400: - description: Bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" 401: @@ -198,6 +201,10 @@ schema: items: $ref: "../swagger.yaml#/definitions/erm_eholdings_package" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" 401: description: Authentication required schema: @@ -264,7 +271,7 @@ items: $ref: "../swagger.yaml#/definitions/erm_eholdings_package" 400: - description: Bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" 403: @@ -311,7 +318,7 @@ 204: description: package deleted 400: - description: package deletion failed + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" 401: @@ -379,6 +386,10 @@ description: Add or remove this package from remote holdings type: boolean additionalProperties: false + 400: + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" 401: description: Authentication required schema: diff --git a/api/v1/swagger/paths/erm_eholdings_packages_resources.yaml b/api/v1/swagger/paths/erm_eholdings_packages_resources.yaml index 8c3ead3e4a0..3d0708303d0 100644 --- a/api/v1/swagger/paths/erm_eholdings_packages_resources.yaml +++ b/api/v1/swagger/paths/erm_eholdings_packages_resources.yaml @@ -59,8 +59,11 @@ items: $ref: "../swagger.yaml#/definitions/erm_eholdings_resource" type: array - 400: - description: Bad request + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" 403: diff --git a/api/v1/swagger/paths/erm_eholdings_resources.yaml b/api/v1/swagger/paths/erm_eholdings_resources.yaml index 254bc86293c..ac14f4ba189 100644 --- a/api/v1/swagger/paths/erm_eholdings_resources.yaml +++ b/api/v1/swagger/paths/erm_eholdings_resources.yaml @@ -58,8 +58,11 @@ items: $ref: "../swagger.yaml#/definitions/erm_eholdings_resource" type: array - 400: - description: Bad request + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" 403: @@ -113,6 +116,10 @@ schema: items: $ref: "../swagger.yaml#/definitions/erm_eholdings_resource" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" 401: description: Authentication required schema: @@ -174,6 +181,10 @@ description: Add or remove this resource from remote holdings type: boolean additionalProperties: false + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" 401: description: Authentication required schema: diff --git a/api/v1/swagger/paths/erm_eholdings_titles.yaml b/api/v1/swagger/paths/erm_eholdings_titles.yaml index 1a713a8a616..42e5f90af97 100644 --- a/api/v1/swagger/paths/erm_eholdings_titles.yaml +++ b/api/v1/swagger/paths/erm_eholdings_titles.yaml @@ -168,8 +168,11 @@ items: $ref: "../swagger.yaml#/definitions/erm_eholdings_title" type: array - 400: - description: Bad request + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" 403: @@ -218,7 +221,7 @@ items: $ref: "../swagger.yaml#/definitions/erm_eholdings_title" 400: - description: Bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" 401: @@ -283,6 +286,10 @@ schema: items: $ref: "../swagger.yaml#/definitions/erm_eholdings_title" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" 401: description: Authentication required schema: @@ -349,7 +356,7 @@ items: $ref: "../swagger.yaml#/definitions/erm_eholdings_title" 400: - description: Bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" 403: @@ -396,7 +403,7 @@ 204: description: title deleted 400: - description: title deletion failed + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" 401: @@ -462,7 +469,7 @@ type: string additionalProperties: false 400: - description: Bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" 401: diff --git a/api/v1/swagger/paths/erm_eholdings_titles_resources.yaml b/api/v1/swagger/paths/erm_eholdings_titles_resources.yaml index 736f25f784d..bdc5a3d499e 100644 --- a/api/v1/swagger/paths/erm_eholdings_titles_resources.yaml +++ b/api/v1/swagger/paths/erm_eholdings_titles_resources.yaml @@ -59,8 +59,11 @@ items: $ref: "../swagger.yaml#/definitions/erm_eholdings_resource" type: array - 400: - description: Bad request + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" 403: diff --git a/api/v1/swagger/paths/erm_licenses.yaml b/api/v1/swagger/paths/erm_licenses.yaml index 51c075c3bd7..266ac331135 100644 --- a/api/v1/swagger/paths/erm_licenses.yaml +++ b/api/v1/swagger/paths/erm_licenses.yaml @@ -67,8 +67,11 @@ items: $ref: "../swagger.yaml#/definitions/erm_license" type: array - 400: - description: Bad request + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" 403: @@ -112,7 +115,7 @@ items: $ref: "../swagger.yaml#/definitions/erm_license" 400: - description: Bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" 401: @@ -178,6 +181,10 @@ schema: items: $ref: "../swagger.yaml#/definitions/erm_license" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" 401: description: authentication required schema: @@ -239,7 +246,7 @@ items: $ref: "../swagger.yaml#/definitions/erm_license" 400: - description: bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" 403: @@ -285,7 +292,7 @@ 204: description: license deleted 400: - description: license deletion failed + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" 401: diff --git a/api/v1/swagger/paths/erm_users.yaml b/api/v1/swagger/paths/erm_users.yaml index e9725c4fcac..82a1fd9bd19 100644 --- a/api/v1/swagger/paths/erm_users.yaml +++ b/api/v1/swagger/paths/erm_users.yaml @@ -34,8 +34,11 @@ type: array items: $ref: "../swagger.yaml#/definitions/patron" - 400: - description: Bad request + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" 403: diff --git a/api/v1/swagger/paths/holds.yaml b/api/v1/swagger/paths/holds.yaml index d10bed8f390..0ef27827480 100644 --- a/api/v1/swagger/paths/holds.yaml +++ b/api/v1/swagger/paths/holds.yaml @@ -106,6 +106,13 @@ description: A list of holds schema: $ref: "../swagger.yaml#/definitions/holds" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -218,7 +225,7 @@ schema: $ref: "../swagger.yaml#/definitions/hold" "400": - description: Missing or wrong parameters + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -285,7 +292,7 @@ schema: $ref: "../swagger.yaml#/definitions/hold" "400": - description: Missing or wrong parameters + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -353,7 +360,7 @@ schema: $ref: "../swagger.yaml#/definitions/hold" "400": - description: Missing or wrong parameters + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -407,6 +414,10 @@ description: Hold request recorded "204": description: Hold deleted + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -455,6 +466,10 @@ description: The new priority value for the hold schema: type: integer + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -514,7 +529,7 @@ "201": description: Hold suspended "400": - description: Missing or wrong parameters + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -559,7 +574,7 @@ "204": description: Hold resumed "400": - description: Missing or wrong parameters + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -625,7 +640,10 @@ items: $ref: "../swagger.yaml#/definitions/library" "400": - description: Missing or wrong parameters + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -688,7 +706,7 @@ description: Internal identifier for the pickup library additionalProperties: false "400": - description: Missing or wrong parameters + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": diff --git a/api/v1/swagger/paths/ill_backends.yaml b/api/v1/swagger/paths/ill_backends.yaml index 874481a5ec9..eb578c8a9ea 100644 --- a/api/v1/swagger/paths/ill_backends.yaml +++ b/api/v1/swagger/paths/ill_backends.yaml @@ -14,6 +14,10 @@ description: A list of ILL backends schema: $ref: "../swagger.yaml#/definitions/ill_backends" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -70,6 +74,10 @@ description: An ILL backends schema: $ref: "../swagger.yaml#/definitions/ill_backend" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -95,4 +103,4 @@ $ref: "../swagger.yaml#/definitions/error" x-koha-authorization: permissions: - ill: "1" \ No newline at end of file + ill: "1" diff --git a/api/v1/swagger/paths/ill_requests.yaml b/api/v1/swagger/paths/ill_requests.yaml index 3ba3f2ca3c6..862a0c88896 100644 --- a/api/v1/swagger/paths/ill_requests.yaml +++ b/api/v1/swagger/paths/ill_requests.yaml @@ -41,6 +41,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/ill_request" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: diff --git a/api/v1/swagger/paths/import_batch_profiles.yaml b/api/v1/swagger/paths/import_batch_profiles.yaml index d5b9ea1b29f..cc9de530928 100644 --- a/api/v1/swagger/paths/import_batch_profiles.yaml +++ b/api/v1/swagger/paths/import_batch_profiles.yaml @@ -29,6 +29,13 @@ description: A list of import batch profiles schema: $ref: "../swagger.yaml#/definitions/import_batch_profiles" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -129,7 +136,7 @@ schema: $ref: "../swagger.yaml#/definitions/import_batch_profile" "400": - description: Missing or wrong parameters + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -238,7 +245,7 @@ schema: $ref: "../swagger.yaml#/definitions/import_batch_profile" "400": - description: Missing or wrong parameters + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -280,6 +287,10 @@ responses: "204": description: Profile deleted + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/import_batches.yaml b/api/v1/swagger/paths/import_batches.yaml index 0fe737a040c..9b205d095c3 100644 --- a/api/v1/swagger/paths/import_batches.yaml +++ b/api/v1/swagger/paths/import_batches.yaml @@ -36,7 +36,7 @@ "200": description: Match updated "400": - description: Missing or wrong parameters + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -87,6 +87,10 @@ responses: "204": description: Matches unchosen + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/item_types.yaml b/api/v1/swagger/paths/item_types.yaml index d359a40d627..0d2bbb206ab 100644 --- a/api/v1/swagger/paths/item_types.yaml +++ b/api/v1/swagger/paths/item_types.yaml @@ -32,8 +32,11 @@ items: $ref: "../swagger.yaml#/definitions/item_type" type: array - 400: - description: Bad request + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" 403: diff --git a/api/v1/swagger/paths/items.yaml b/api/v1/swagger/paths/items.yaml index 154ed59fd83..630d490782a 100644 --- a/api/v1/swagger/paths/items.yaml +++ b/api/v1/swagger/paths/items.yaml @@ -42,6 +42,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/item" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -93,7 +100,7 @@ schema: $ref: "../swagger.yaml#/definitions/item" "400": - description: Missing or wrong parameters + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "404": @@ -130,7 +137,7 @@ "204": description: Deleted item "400": - description: Missing or wrong parameters + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "403": @@ -192,7 +199,7 @@ items: $ref: "../swagger.yaml#/definitions/item" "400": - description: Bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -267,6 +274,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/item" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -308,7 +322,7 @@ "204": description: Bundle link deleted "400": - description: Bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "409": @@ -372,7 +386,10 @@ items: $ref: "../swagger.yaml#/definitions/library" "400": - description: Missing or wrong parameters + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -443,6 +460,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/item" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/jobs.yaml b/api/v1/swagger/paths/jobs.yaml index 62ae157dc07..2eef440f57f 100644 --- a/api/v1/swagger/paths/jobs.yaml +++ b/api/v1/swagger/paths/jobs.yaml @@ -29,6 +29,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/job" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -63,6 +70,10 @@ description: A job schema: $ref: "../swagger.yaml#/definitions/job" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: diff --git a/api/v1/swagger/paths/libraries.yaml b/api/v1/swagger/paths/libraries.yaml index 045f884a6da..e5b2bcff894 100644 --- a/api/v1/swagger/paths/libraries.yaml +++ b/api/v1/swagger/paths/libraries.yaml @@ -114,6 +114,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/library" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "500": description: | Internal server error. Possible `error_code` attribute values: @@ -204,6 +211,10 @@ description: A library schema: $ref: "../swagger.yaml#/definitions/library" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "404": description: Library not found schema: @@ -279,6 +290,10 @@ description: Library deleted schema: type: string + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -330,6 +345,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/library" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "500": description: | Internal server error. Possible `error_code` attribute values: @@ -355,6 +377,10 @@ responses: "200": description: A library + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/oauth.yaml b/api/v1/swagger/paths/oauth.yaml index 2b3f2fb029f..27e08379fc7 100644 --- a/api/v1/swagger/paths/oauth.yaml +++ b/api/v1/swagger/paths/oauth.yaml @@ -36,7 +36,7 @@ type: integer additionalProperties: false "400": - description: Bad Request + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "403": @@ -108,7 +108,7 @@ schema: type: string "400": - description: Bad Request + description: Bad request schema: $ref: ../swagger.yaml#/definitions/error "403": diff --git a/api/v1/swagger/paths/patrons.yaml b/api/v1/swagger/paths/patrons.yaml index 1100a9fba96..a3be8664292 100644 --- a/api/v1/swagger/paths/patrons.yaml +++ b/api/v1/swagger/paths/patrons.yaml @@ -368,6 +368,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/patron" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -417,7 +424,13 @@ items: $ref: "../swagger.yaml#/definitions/patron" "400": - description: Bad parameter + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_attribute_type` + * `attribute_not_unique` + * `non_repeatable_attribute` + * `missing_mandatory_attribute` schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -476,6 +489,10 @@ description: A patron schema: $ref: "../swagger.yaml#/definitions/patron" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -527,7 +544,13 @@ items: $ref: "../swagger.yaml#/definitions/patron" "400": - description: Bad parameter + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_attribute_type` + * `attribute_not_unique` + * `non_repeatable_attribute` + * `missing_mandatory_attribute` schema: $ref: "../swagger.yaml#/definitions/error" "403": @@ -570,7 +593,7 @@ "204": description: Patron deleted "400": - description: Patron deletion failed + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": diff --git a/api/v1/swagger/paths/patrons_account.yaml b/api/v1/swagger/paths/patrons_account.yaml index df1422764a5..ff48b2342ea 100644 --- a/api/v1/swagger/paths/patrons_account.yaml +++ b/api/v1/swagger/paths/patrons_account.yaml @@ -15,6 +15,10 @@ description: Patron's account balance schema: $ref: "../swagger.yaml#/definitions/patron_balance" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -67,6 +71,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/credit" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -104,6 +115,10 @@ description: Credit added schema: $ref: "../swagger.yaml#/definitions/account_line" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -155,6 +170,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/debit" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -197,7 +219,7 @@ schema: $ref: "../swagger.yaml#/definitions/debit" "400": - description: Bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": diff --git a/api/v1/swagger/paths/patrons_extended_attributes.yaml b/api/v1/swagger/paths/patrons_extended_attributes.yaml index 1b29f68a364..6077f80acf4 100644 --- a/api/v1/swagger/paths/patrons_extended_attributes.yaml +++ b/api/v1/swagger/paths/patrons_extended_attributes.yaml @@ -25,6 +25,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/patron_extended_attribute" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -73,7 +80,7 @@ schema: $ref: "../swagger.yaml#/definitions/patron_extended_attribute" "400": - description: Bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -132,7 +139,7 @@ items: $ref: "../swagger.yaml#/definitions/patron_extended_attribute" "400": - description: Bad parameters + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -199,7 +206,7 @@ schema: $ref: "../swagger.yaml#/definitions/patron_extended_attribute" "400": - description: Bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -250,6 +257,10 @@ responses: "204": description: Extended patron attribute deleted + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/patrons_holds.yaml b/api/v1/swagger/paths/patrons_holds.yaml index 17f79c24c82..a19f414fbf3 100644 --- a/api/v1/swagger/paths/patrons_holds.yaml +++ b/api/v1/swagger/paths/patrons_holds.yaml @@ -35,6 +35,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/hold" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/public_oauth.yaml b/api/v1/swagger/paths/public_oauth.yaml index 80ac4e3741d..75bcd10666a 100644 --- a/api/v1/swagger/paths/public_oauth.yaml +++ b/api/v1/swagger/paths/public_oauth.yaml @@ -63,9 +63,12 @@ schema: type: string "400": - description: Bad Request + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: - $ref: ../swagger.yaml#/definitions/error + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: diff --git a/api/v1/swagger/paths/quotes.yaml b/api/v1/swagger/paths/quotes.yaml index b8646e52eac..3876f7c85df 100644 --- a/api/v1/swagger/paths/quotes.yaml +++ b/api/v1/swagger/paths/quotes.yaml @@ -44,6 +44,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/quote" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -82,6 +89,10 @@ description: Quote added schema: $ref: "../swagger.yaml#/definitions/quote" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -120,6 +131,10 @@ description: A Quote schema: $ref: "../swagger.yaml#/definitions/quote" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "404": description: Quote not found schema: @@ -159,6 +174,10 @@ description: A quote schema: $ref: "../swagger.yaml#/definitions/quote" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -198,6 +217,10 @@ responses: "204": description: Quote deleted + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/rotas.yaml b/api/v1/swagger/paths/rotas.yaml index 96eef748301..6cadbc28c11 100644 --- a/api/v1/swagger/paths/rotas.yaml +++ b/api/v1/swagger/paths/rotas.yaml @@ -29,7 +29,10 @@ "200": description: OK "400": - description: Bad request + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" "401": diff --git a/api/v1/swagger/paths/search_filters.yaml b/api/v1/swagger/paths/search_filters.yaml index 6589b1e6c19..8f7632ccbf7 100644 --- a/api/v1/swagger/paths/search_filters.yaml +++ b/api/v1/swagger/paths/search_filters.yaml @@ -24,6 +24,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/search_filter" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" '403': description: Access forbidden schema: @@ -59,6 +66,10 @@ description: Search filter added schema: $ref: "../swagger.yaml#/definitions/search_filter" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" '401': description: Authentication required schema: @@ -98,6 +109,10 @@ description: A search filter schema: $ref: "../swagger.yaml#/definitions/search_filter" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" '403': description: Access forbidden schema: @@ -138,6 +153,10 @@ description: An search_filter schema: $ref: "../swagger.yaml#/definitions/search_filter" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" '401': description: Authentication required schema: @@ -176,6 +195,10 @@ description: Searc filter deleted schema: type: string + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" '401': description: Authentication required schema: diff --git a/api/v1/swagger/paths/suggestions.yaml b/api/v1/swagger/paths/suggestions.yaml index 54381885916..9e0cc9296a2 100644 --- a/api/v1/swagger/paths/suggestions.yaml +++ b/api/v1/swagger/paths/suggestions.yaml @@ -25,6 +25,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/suggestion" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -119,6 +126,10 @@ description: A suggestion schema: $ref: "../swagger.yaml#/definitions/suggestion" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -205,6 +216,10 @@ description: Suggestion deleted schema: type: string + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -266,6 +281,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/patron" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: diff --git a/api/v1/swagger/paths/tickets.yaml b/api/v1/swagger/paths/tickets.yaml index 709d5509b5e..a329c811d97 100644 --- a/api/v1/swagger/paths/tickets.yaml +++ b/api/v1/swagger/paths/tickets.yaml @@ -37,6 +37,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/ticket" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -75,6 +82,10 @@ description: Ticket added schema: $ref: "../swagger.yaml#/definitions/ticket" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -113,6 +124,13 @@ description: A ticket schema: $ref: "../swagger.yaml#/definitions/ticket" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "404": description: Ticket not found schema: @@ -152,6 +170,10 @@ description: A ticket schema: $ref: "../swagger.yaml#/definitions/ticket" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -188,6 +210,10 @@ responses: "204": description: Ticket deleted + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -247,6 +273,13 @@ type: array items: $ref: "../swagger.yaml#/definitions/ticket_update" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" "403": description: Access forbidden schema: @@ -290,6 +323,10 @@ description: Ticket added schema: $ref: "../swagger.yaml#/definitions/ticket_update" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -334,6 +371,10 @@ description: Ticket added schema: $ref: "../swagger.yaml#/definitions/ticket" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/api/v1/swagger/paths/transfer_limits.yaml b/api/v1/swagger/paths/transfer_limits.yaml index f73a1d31d92..6631fc3d8e2 100644 --- a/api/v1/swagger/paths/transfer_limits.yaml +++ b/api/v1/swagger/paths/transfer_limits.yaml @@ -45,7 +45,10 @@ items: $ref: "../swagger.yaml#/definitions/transfer_limit" "400": - description: Bad request + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -139,6 +142,10 @@ description: Transfer limit deleted schema: type: string + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -314,6 +321,10 @@ responses: "204": description: Transfer limits deleted + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: diff --git a/t/db_dependent/api/v1/query.t b/t/db_dependent/api/v1/query.t index 353760ca996..f807f21ea2b 100755 --- a/t/db_dependent/api/v1/query.t +++ b/t/db_dependent/api/v1/query.t @@ -171,7 +171,7 @@ subtest 'SQL injection in "query" handling' => sub { "[{\"-and\":[[{\"me.patron_id\":{\"like(IF(ASCII(SUBSTRING((SELECT version()),1,1))=ASCII('1'),SLEEP(1/100000),0))or\":\"\%a\%\"}}]]}]"; $t->get_ok("//$userid:$password@/api/v1/patrons?q=$q") - ->status_is( 500, 'Attempt to inject SQL through operators is rejected' ); + ->status_is( 400, 'Attempt to inject SQL through operators is rejected' ); $schema->storage->txn_rollback; }; diff --git a/xt/api.t b/xt/api.t index 0dc8dccb869..e1ad544b11d 100755 --- a/xt/api.t +++ b/xt/api.t @@ -14,10 +14,11 @@ use Modern::Perl; -use Test::More tests => 3; +use Test::More tests => 4; use Test::Mojo; use Data::Dumper; +use List::MoreUtils qw(any); use FindBin(); use IPC::Cmd qw(can_run); @@ -93,3 +94,46 @@ subtest 'The spec passes the swagger-cli validation' => sub { or diag $var; } }; + +subtest '400 response tests' => sub { + + plan tests => 1; + + my @errors; + + foreach my $route ( sort keys %{$paths} ) { + foreach my $verb ( keys %{ $paths->{$route} } ) { + + my $response_400 = $paths->{$route}->{$verb}->{responses}->{400}; + + if ( !$response_400 ) { + push @errors, "$verb $route -> response 400 absent"; + next; + } + + push @errors, + "$verb $route -> 'description' does not start with 'Bad request': ($response_400->{description})" + unless $response_400->{description} =~ /^Bad request/; + + my $ref = $response_400->{schema}->{'$ref'}; + push @errors, "$verb $route -> '\$ref' is not '#/definitions/error': ($ref)" + unless $ref =~ m/^#\/definitions\/error/; + + # GET routes with q parameter must mention the `invalid_query` error code + if ( ( any { $_->{in} eq 'body' && $_->{name} eq 'query' } @{ $paths->{$route}->{$verb}->{parameters} } ) + || ( any { $_->{in} eq 'query' && $_->{name} eq 'q' } @{ $paths->{$route}->{$verb}->{parameters} } ) ) + { + + push @errors, + "$verb $route -> 'description' does not include '* \`invalid_query\`': ($response_400->{description})" + unless $response_400->{description} =~ /\* \`invalid_query\`/; + } + } + } + + is( scalar @errors, 0, 'No errors in 400 definitions in the spec' ); + + foreach my $error (@errors) { + print STDERR "$error\n"; + } +}; -- 2.45.2