From 011a85d37cf139433301b23cb81a167f67d86ff9 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 8 Jul 2024 17:21:25 -0300 Subject: [PATCH] Bug 37018: Add 400 response definition to all routes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Frédéric Demians --- 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/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/items.yaml | 25 +++++- 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 | 8 ++ .../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/transfer_limits.yaml | 27 ++++++ t/db_dependent/api/v1/query.t | 2 +- xt/api.t | 46 ++++++++++- 48 files changed, 752 insertions(+), 80 deletions(-) diff --git a/Koha/REST/Plugin/Exceptions.pm b/Koha/REST/Plugin/Exceptions.pm index 7a78913b0c..6053a99630 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 89b7d7e42b..7dd594750a 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 31f0455e5b..eb76fac6ff 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 4101e72ad6..9f58bdc524 100644 --- a/api/v1/swagger/paths/acquisitions_orders.yaml +++ b/api/v1/swagger/paths/acquisitions_orders.yaml @@ -73,6 +73,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: @@ -190,6 +197,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: @@ -237,6 +248,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: @@ -276,6 +291,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 f5275ddfe1..b0bd0d16f3 100644 --- a/api/v1/swagger/paths/acquisitions_vendors.yaml +++ b/api/v1/swagger/paths/acquisitions_vendors.yaml @@ -34,6 +34,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: @@ -80,6 +87,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: @@ -122,6 +133,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: @@ -169,6 +184,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: @@ -208,6 +227,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 0cb4c34323..40f5615ba0 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 b893db9d91..1c28ebe0c7 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 f5f8387e4a..1806e29e57 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 298f3ec229..53bac0726f 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/biblios.yaml b/api/v1/swagger/paths/biblios.yaml index a3843d13af..a1146a9316 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: @@ -443,7 +472,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": @@ -489,6 +521,10 @@ responses: "200": description: A biblio + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "401": description: Authentication required schema: @@ -546,6 +582,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: @@ -619,6 +662,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 0e44049dd6..b6a098cfb6 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 719a932e8e..82372b8335 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 d20aaa1f7d..758a899b9f 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 545f15458a..b5f9222099 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 c8f29ef663..a376c4dc14 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 7e09954d7c..9d04355ee2 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 effe1d8642..82428b1e53 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 655fed2e3a..8e633ead71 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 faa824d5b0..e938972d77 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 80be3279b3..a0b4426675 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 0237e6fcfb..31f8fdff31 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 8c3ead3e4a..3d0708303d 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 254bc86293..ac14f4ba18 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 1a713a8a61..42e5f90af9 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 736f25f784..bdc5a3d499 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 51c075c3bd..266ac33113 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 e9725c4fca..82a1fd9bd1 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 d10bed8f39..0ef2782748 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 874481a5ec..eb578c8a9e 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 3ba3f2ca3c..862a0c8889 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 d5b9ea1b29..cc9de53092 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 0fe737a040..9b205d095c 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/items.yaml b/api/v1/swagger/paths/items.yaml index d4b0d8f820..8a9dc2a18e 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": @@ -140,7 +147,7 @@ items: $ref: "../swagger.yaml#/definitions/item" "400": - description: Bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "401": @@ -215,6 +222,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: @@ -256,7 +270,7 @@ "204": description: Bundle link deleted "400": - description: Bad parameter + description: Bad request schema: $ref: "../swagger.yaml#/definitions/error" "409": @@ -320,7 +334,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": diff --git a/api/v1/swagger/paths/jobs.yaml b/api/v1/swagger/paths/jobs.yaml index 62ae157dc0..2eef440f57 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 045f884a6d..e5b2bcff89 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 2b3f2fb029..27e08379fc 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 1100a9fba9..a3be866429 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 3f763a7aa4..91b70a4612 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: @@ -64,6 +68,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: diff --git a/api/v1/swagger/paths/patrons_extended_attributes.yaml b/api/v1/swagger/paths/patrons_extended_attributes.yaml index 1b29f68a36..6077f80acf 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 ec075bd75c..e64d9b6d10 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 80ac4e3741..75bcd10666 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 b8646e52ea..3876f7c85d 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 96eef74830..6cadbc28c1 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 6589b1e6c1..8f7632ccbf 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 5438188591..9e0cc9296a 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/transfer_limits.yaml b/api/v1/swagger/paths/transfer_limits.yaml index 5680dedbcf..5ef0530927 100644 --- a/api/v1/swagger/paths/transfer_limits.yaml +++ b/api/v1/swagger/paths/transfer_limits.yaml @@ -44,6 +44,21 @@ type: array items: $ref: "../swagger.yaml#/definitions/transfer_limit" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `invalid_query` + schema: + $ref: "../swagger.yaml#/definitions/error" + "401": + description: Authentication required + schema: + $ref: "../swagger.yaml#/definitions/error" + "403": + description: Access forbidden + schema: + $ref: "../swagger.yaml#/definitions/error" "500": description: | Internal server error. Possible `error_code` attribute values: @@ -127,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: @@ -232,6 +251,10 @@ type: array items: $ref: "../swagger.yaml#/definitions/transfer_limit" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" "500": description: | Internal server error. Possible `error_code` attribute values: @@ -288,6 +311,10 @@ description: Transfer limits deleted schema: type: string + "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 353760ca99..f807f21ea2 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 0dc8dccb86..e1ad544b11 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.39.5