From 5086feeab0b9b803b67de5b0a10d53f8a154069f Mon Sep 17 00:00:00 2001
From: Tomas Cohen Arazi <tomascohen@theke.io>
Date: Mon, 8 Jul 2024 17:21:25 -0300
Subject: [PATCH] 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 <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
---
 Koha/REST/Plugin/Exceptions.pm                |  2 +-
 .../swagger/paths/acquisitions_baskets.yaml   |  7 ++
 .../swagger/paths/acquisitions_edifiles.yaml  |  7 ++
 api/v1/swagger/paths/acquisitions_funds.yaml  | 21 +++++
 api/v1/swagger/paths/acquisitions_orders.yaml | 19 +++++
 .../paths/acquisitions_vendor_issues.yaml     |  7 ++
 .../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             | 56 ++++++++++++-
 api/v1/swagger/paths/biblios_item_groups.yaml | 19 ++++-
 api/v1/swagger/paths/biblios_merge.yaml       |  4 +
 api/v1/swagger/paths/bookings.yaml            | 19 ++++-
 api/v1/swagger/paths/cash_registers.yaml      | 11 +++
 api/v1/swagger/paths/checkouts.yaml           | 37 ++++++++-
 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/deleted_biblios.yaml     | 11 +++
 api/v1/swagger/paths/erm_agreements.yaml      | 17 ++--
 api/v1/swagger/paths/erm_counter_files.yaml   | 13 ++-
 api/v1/swagger/paths/erm_counter_logs.yaml    |  7 +-
 .../swagger/paths/erm_counter_registries.yaml |  7 +-
 api/v1/swagger/paths/erm_custom_reports.yaml  | 30 ++++++-
 .../paths/erm_default_usage_reports.yaml      | 15 ++--
 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   | 21 +++--
 .../paths/erm_eholdings_titles_resources.yaml |  7 +-
 api/v1/swagger/paths/erm_licenses.yaml        | 17 ++--
 api/v1/swagger/paths/erm_sushi_services.yaml  |  7 +-
 .../paths/erm_usage_data_providers.yaml       | 23 ++++--
 api/v1/swagger/paths/erm_usage_databases.yaml |  9 +-
 api/v1/swagger/paths/erm_usage_items.yaml     |  9 +-
 api/v1/swagger/paths/erm_usage_platforms.yaml |  9 +-
 api/v1/swagger/paths/erm_usage_titles.yaml    |  7 +-
 api/v1/swagger/paths/erm_users.yaml           |  7 +-
 .../paths/extended_attribute_types.yaml       |  7 +-
 api/v1/swagger/paths/holds.yaml               | 32 ++++++--
 api/v1/swagger/paths/ill_backends.yaml        | 10 ++-
 api/v1/swagger/paths/ill_batches.yaml         | 18 ++++
 api/v1/swagger/paths/ill_batchstatuses.yaml   | 12 +++
 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               | 41 ++++++++--
 api/v1/swagger/paths/jobs.yaml                | 11 +++
 api/v1/swagger/paths/libraries.yaml           | 40 +++++++++
 api/v1/swagger/paths/oauth.yaml               |  4 +-
 api/v1/swagger/paths/patron_categories.yaml   |  7 ++
 api/v1/swagger/paths/patrons.yaml             | 17 +++-
 api/v1/swagger/paths/patrons_account.yaml     | 24 +++++-
 api/v1/swagger/paths/patrons_checkouts.yaml   |  7 ++
 .../paths/patrons_extended_attributes.yaml    | 17 +++-
 api/v1/swagger/paths/patrons_holds.yaml       |  7 ++
 api/v1/swagger/paths/patrons_recalls.yaml     |  7 ++
 .../paths/preservation_processings.yaml       | 23 ++++--
 api/v1/swagger/paths/preservation_trains.yaml | 45 ++++++----
 .../paths/preservation_waiting_list.yaml      | 11 ++-
 api/v1/swagger/paths/public_oauth.yaml        |  7 +-
 api/v1/swagger/paths/public_patrons.yaml      |  2 +-
 api/v1/swagger/paths/quotes.yaml              | 23 ++++++
 api/v1/swagger/paths/record_sources.yaml      | 13 +--
 api/v1/swagger/paths/rotas.yaml               | 23 ++++++
 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                                      | 45 +++++++++-
 77 files changed, 1122 insertions(+), 162 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 4767ac155e3..f3e8a0d2cb3 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_edifiles.yaml b/api/v1/swagger/paths/acquisitions_edifiles.yaml
index 518d86bcf06..99de6d59491 100644
--- a/api/v1/swagger/paths/acquisitions_edifiles.yaml
+++ b/api/v1/swagger/paths/acquisitions_edifiles.yaml
@@ -35,6 +35,13 @@
           type: array
           items:
             $ref: "../swagger.yaml#/definitions/edifact_file"
+      "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/acquisitions_funds.yaml b/api/v1/swagger/paths/acquisitions_funds.yaml
index 0aa0f210836..9c45ebd94ac 100644
--- a/api/v1/swagger/paths/acquisitions_funds.yaml
+++ b/api/v1/swagger/paths/acquisitions_funds.yaml
@@ -33,6 +33,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:
@@ -94,6 +101,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:
@@ -147,6 +161,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 caa47d85aa1..804fd9a4b23 100644
--- a/api/v1/swagger/paths/acquisitions_orders.yaml
+++ b/api/v1/swagger/paths/acquisitions_orders.yaml
@@ -74,6 +74,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:
@@ -191,6 +198,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:
@@ -238,6 +249,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:
@@ -277,6 +292,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_vendor_issues.yaml b/api/v1/swagger/paths/acquisitions_vendor_issues.yaml
index d55cb2a8843..be2dc58ee7e 100644
--- a/api/v1/swagger/paths/acquisitions_vendor_issues.yaml
+++ b/api/v1/swagger/paths/acquisitions_vendor_issues.yaml
@@ -64,6 +64,13 @@
           type: array
           items:
             $ref: "../swagger.yaml#/definitions/vendor_issue"
+      "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/acquisitions_vendors.yaml b/api/v1/swagger/paths/acquisitions_vendors.yaml
index 7af2fbc48a4..ed817cc2a1d 100644
--- a/api/v1/swagger/paths/acquisitions_vendors.yaml
+++ b/api/v1/swagger/paths/acquisitions_vendors.yaml
@@ -43,6 +43,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:
@@ -89,6 +96,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:
@@ -131,6 +142,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:
@@ -178,6 +193,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:
@@ -217,6 +236,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 b6ad3c731a8..e288d2fc176 100644
--- a/api/v1/swagger/paths/advancededitormacros.yaml
+++ b/api/v1/swagger/paths/advancededitormacros.yaml
@@ -43,6 +43,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:
@@ -81,6 +88,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:
@@ -121,6 +132,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:
@@ -158,6 +173,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:
@@ -198,6 +217,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:
@@ -236,6 +259,10 @@
         description: Advanced editor macro deleted
         schema:
           type: string
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -275,6 +302,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:
@@ -315,6 +346,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:
@@ -355,6 +390,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 b9dee70cdca..052565e4de6 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":
@@ -163,9 +163,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:
@@ -225,7 +228,7 @@
         schema:
           $ref: ../swagger.yaml#/definitions/auth_provider
       "400":
-        description: Bad Request
+        description: Bad request
         schema:
           $ref: ../swagger.yaml#/definitions/error
       "403":
@@ -272,6 +275,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:
@@ -332,7 +339,7 @@
         schema:
           $ref: ../swagger.yaml#/definitions/auth_provider
       "400":
-        description: Bad Request
+        description: Bad request
         schema:
           $ref: ../swagger.yaml#/definitions/error
       "403":
@@ -370,6 +377,10 @@
     responses:
       "204":
         description: identity provider deleted
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -428,6 +439,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:
@@ -468,7 +486,7 @@
         schema:
           $ref: ../swagger.yaml#/definitions/auth_provider_domain
       "400":
-        description: Bad Request
+        description: Bad request
         schema:
           $ref: ../swagger.yaml#/definitions/error
       "403":
@@ -510,6 +528,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:
@@ -542,6 +564,10 @@
     responses:
       "204":
         description: identity provider deleted
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -601,9 +627,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:
@@ -663,7 +692,7 @@
         schema:
           $ref: ../swagger.yaml#/definitions/identity_provider
       "400":
-        description: Bad Request
+        description: Bad request
         schema:
           $ref: ../swagger.yaml#/definitions/error
       "403":
@@ -710,6 +739,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:
@@ -770,7 +803,7 @@
         schema:
           $ref: ../swagger.yaml#/definitions/identity_provider
       "400":
-        description: Bad Request
+        description: Bad request
         schema:
           $ref: ../swagger.yaml#/definitions/error
       "403":
@@ -807,7 +840,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:
@@ -866,6 +903,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:
@@ -906,7 +950,7 @@
         schema:
           $ref: ../swagger.yaml#/definitions/identity_provider_domain
       "400":
-        description: Bad Request
+        description: Bad request
         schema:
           $ref: ../swagger.yaml#/definitions/error
       "403":
@@ -948,6 +992,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:
@@ -989,7 +1037,7 @@
         schema:
           $ref: ../swagger.yaml#/definitions/identity_provider_domain
       "400":
-        description: Bad Request
+        description: Bad request
         schema:
           $ref: ../swagger.yaml#/definitions/error
       "403":
@@ -1028,6 +1076,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 dc33c378477..dbb79585062 100644
--- a/api/v1/swagger/paths/authorised_value_categories.yaml
+++ b/api/v1/swagger/paths/authorised_value_categories.yaml
@@ -33,7 +33,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 07e298dc217..f1bea9e92db 100644
--- a/api/v1/swagger/paths/authorised_values.yaml
+++ b/api/v1/swagger/paths/authorised_values.yaml
@@ -58,7 +58,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 17fb83ece62..05d1e39330e 100644
--- a/api/v1/swagger/paths/authorities.yaml
+++ b/api/v1/swagger/paths/authorities.yaml
@@ -23,6 +23,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:
@@ -91,7 +98,7 @@
       "201":
         description: An authority
       "400":
-        description: Bad request.
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -148,6 +155,10 @@
     responses:
       "200":
         description: An authority
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -196,6 +207,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 2da90e27d62..005d75ec231 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:
@@ -313,6 +328,13 @@
           type: array
           items:
             $ref: ../swagger.yaml#/definitions/booking
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -385,6 +407,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:
@@ -474,6 +503,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:
@@ -651,7 +687,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":
@@ -697,6 +736,10 @@
     responses:
       "200":
         description: A biblio
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -763,6 +806,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:
@@ -836,6 +886,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 7491220fb9e..4576411db05 100644
--- a/api/v1/swagger/paths/biblios_item_groups.yaml
+++ b/api/v1/swagger/paths/biblios_item_groups.yaml
@@ -37,6 +37,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:
@@ -90,7 +97,7 @@
         schema:
           "$ref": "../swagger.yaml#/definitions/item_group"
       '400':
-        description: Bad parameter
+        description: Bad request
         schema:
           "$ref": "../swagger.yaml#/definitions/error"
       '401':
@@ -156,7 +163,7 @@
         schema:
           "$ref": "../swagger.yaml#/definitions/item_group"
       '400':
-        description: Missing or wrong parameters
+        description: Bad request
         schema:
           "$ref": "../swagger.yaml#/definitions/error"
       '404':
@@ -273,6 +280,10 @@
         description: ItemGroup deleted
         schema:
           type: string
+      '400':
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       '401':
         description: Authentication required
         schema:
@@ -397,6 +408,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/biblios_merge.yaml b/api/v1/swagger/paths/biblios_merge.yaml
index cf83b5236fb..d3608ea35bb 100644
--- a/api/v1/swagger/paths/biblios_merge.yaml
+++ b/api/v1/swagger/paths/biblios_merge.yaml
@@ -24,6 +24,10 @@
     responses:
       '200':
         description: The merge result as a biblio record
+      '400':
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       '404':
         description: Biblio not found
         schema:
diff --git a/api/v1/swagger/paths/bookings.yaml b/api/v1/swagger/paths/bookings.yaml
index 35a50a34108..9cb8a8546cf 100644
--- a/api/v1/swagger/paths/bookings.yaml
+++ b/api/v1/swagger/paths/bookings.yaml
@@ -57,6 +57,13 @@
           items:
             $ref: ../swagger.yaml#/definitions/booking
           type: array
+      400:
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       403:
         description: Access forbidden
         schema:
@@ -92,7 +99,7 @@
         schema:
           $ref: ../swagger.yaml#/definitions/booking
       400:
-        description: Client error
+        description: Bad request
         schema:
           $ref: ../swagger.yaml#/definitions/error
       401:
@@ -132,6 +139,10 @@
     responses:
       204:
         description: Booking deleted
+      400:
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       401:
         description: Authentication required
         schema:
@@ -170,6 +181,10 @@
         description: A booking
         schema:
           $ref: ../swagger.yaml#/definitions/booking
+      400:
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       404:
         description: Booking not found
         schema:
@@ -207,7 +222,7 @@
         schema:
           $ref: ../swagger.yaml#/definitions/booking
       400:
-        description: Client error
+        description: Bad request
         schema:
           $ref: ../swagger.yaml#/definitions/error
       401:
diff --git a/api/v1/swagger/paths/cash_registers.yaml b/api/v1/swagger/paths/cash_registers.yaml
index 632fa2274f5..4fb4dff012c 100644
--- a/api/v1/swagger/paths/cash_registers.yaml
+++ b/api/v1/swagger/paths/cash_registers.yaml
@@ -34,6 +34,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:
@@ -82,6 +89,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 5964f61cb74..24199736e1f 100644
--- a/api/v1/swagger/paths/checkouts.yaml
+++ b/api/v1/swagger/paths/checkouts.yaml
@@ -38,6 +38,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:
@@ -90,7 +97,7 @@
         schema:
           $ref: "../swagger.yaml#/definitions/checkout"
       "400":
-        description: Missing or wrong parameters
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -150,6 +157,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:
@@ -189,6 +200,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:
@@ -228,6 +243,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:
@@ -275,6 +294,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:
@@ -313,6 +336,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:
@@ -352,6 +379,10 @@
         description: Availability
         schema:
           $ref: "../swagger.yaml#/definitions/checkout_availability"
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "403":
         description: Access forbidden
         schema:
@@ -397,6 +428,10 @@
             confirmation_token:
               type: string
           additionalProperties: false
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "403":
         description: Access forbidden
         schema:
diff --git a/api/v1/swagger/paths/circulation_rules.yaml b/api/v1/swagger/paths/circulation_rules.yaml
index eeba8a20b4f..1c689e2ee09 100644
--- a/api/v1/swagger/paths/circulation_rules.yaml
+++ b/api/v1/swagger/paths/circulation_rules.yaml
@@ -83,6 +83,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 b7e43a32817..2e36d028076 100644
--- a/api/v1/swagger/paths/cities.yaml
+++ b/api/v1/swagger/paths/cities.yaml
@@ -43,6 +43,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:
@@ -81,6 +88,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:
@@ -119,6 +130,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:
@@ -158,6 +173,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:
@@ -194,6 +213,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 e07458a9a86..dc75b2c7aa1 100644
--- a/api/v1/swagger/paths/config_smtp_servers.yaml
+++ b/api/v1/swagger/paths/config_smtp_servers.yaml
@@ -23,6 +23,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:
@@ -61,6 +68,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:
@@ -103,6 +114,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:
@@ -146,6 +161,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:
@@ -185,6 +204,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/deleted_biblios.yaml b/api/v1/swagger/paths/deleted_biblios.yaml
index 5678a2a22a4..e5c6e4fff0d 100644
--- a/api/v1/swagger/paths/deleted_biblios.yaml
+++ b/api/v1/swagger/paths/deleted_biblios.yaml
@@ -23,6 +23,13 @@
     responses:
       "200":
         description: A list of deleted biblios
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -74,6 +81,10 @@
     responses:
       "200":
         description: A deleted biblio
+      "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 4e543f7a8dc..43a48e11790 100644
--- a/api/v1/swagger/paths/erm_agreements.yaml
+++ b/api/v1/swagger/paths/erm_agreements.yaml
@@ -83,8 +83,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:
@@ -128,7 +131,7 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_agreement"
       400:
-        description: Bad parameter
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -202,6 +205,10 @@
         schema:
           items:
             $ref: "../swagger.yaml#/definitions/erm_agreement"
+      400:
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       401:
         description: Authentication required
         schema:
@@ -266,7 +273,7 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_agreement"
       400:
-        description: Bad parameter
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -312,7 +319,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_counter_files.yaml b/api/v1/swagger/paths/erm_counter_files.yaml
index 7e244e948fb..60ac800674b 100644
--- a/api/v1/swagger/paths/erm_counter_files.yaml
+++ b/api/v1/swagger/paths/erm_counter_files.yaml
@@ -19,6 +19,10 @@
         description: A counter file
         schema:
           type: file
+      400:
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       401:
         description: Authentication required
         schema:
@@ -108,7 +112,10 @@
             $ref: "../swagger.yaml#/definitions/erm_counter_file"
           type: array
       400:
-        description: Bad request
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -143,7 +150,7 @@
       204:
         description: counter_file deleted
       400:
-        description: counter_file deletion failed
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -174,4 +181,4 @@
           $ref: "../swagger.yaml#/definitions/error"
     x-koha-authorization:
       permissions:
-        erm: 1
\ No newline at end of file
+        erm: 1
diff --git a/api/v1/swagger/paths/erm_counter_logs.yaml b/api/v1/swagger/paths/erm_counter_logs.yaml
index 01c18ace3fe..2d73cc4302e 100644
--- a/api/v1/swagger/paths/erm_counter_logs.yaml
+++ b/api/v1/swagger/paths/erm_counter_logs.yaml
@@ -27,7 +27,10 @@
             $ref: "../swagger.yaml#/definitions/erm_counter_log"
           type: array
       400:
-        description: Bad request
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -46,4 +49,4 @@
           $ref: "../swagger.yaml#/definitions/error"
     x-koha-authorization:
       permissions:
-        erm: 1
\ No newline at end of file
+        erm: 1
diff --git a/api/v1/swagger/paths/erm_counter_registries.yaml b/api/v1/swagger/paths/erm_counter_registries.yaml
index a39691bf23f..afe2bdc2274 100644
--- a/api/v1/swagger/paths/erm_counter_registries.yaml
+++ b/api/v1/swagger/paths/erm_counter_registries.yaml
@@ -23,7 +23,10 @@
             $ref: "../swagger.yaml#/definitions/erm_counter_registry"
           type: array
       400:
-        description: Bad request
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -42,4 +45,4 @@
           $ref: "../swagger.yaml#/definitions/error"
     x-koha-authorization:
       permissions:
-        erm: 1
\ No newline at end of file
+        erm: 1
diff --git a/api/v1/swagger/paths/erm_custom_reports.yaml b/api/v1/swagger/paths/erm_custom_reports.yaml
index d0bd51949e5..47e4bd53393 100644
--- a/api/v1/swagger/paths/erm_custom_reports.yaml
+++ b/api/v1/swagger/paths/erm_custom_reports.yaml
@@ -32,6 +32,13 @@
         schema:
           items:
             $ref: "../swagger.yaml#/definitions/erm_custom_report"
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       401:
         description: authentication required
         schema:
@@ -91,6 +98,13 @@
         schema:
           items:
             $ref: "../swagger.yaml#/definitions/erm_custom_report"
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       401:
         description: authentication required
         schema:
@@ -150,6 +164,13 @@
         schema:
           items:
             $ref: "../swagger.yaml#/definitions/erm_custom_report"
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       401:
         description: authentication required
         schema:
@@ -212,6 +233,13 @@
         schema:
           items:
             $ref: "../swagger.yaml#/definitions/erm_custom_report"
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       401:
         description: authentication required
         schema:
@@ -236,4 +264,4 @@
           $ref: "../swagger.yaml#/definitions/error"
     x-koha-authorization:
       permissions:
-        erm: 1
\ No newline at end of file
+        erm: 1
diff --git a/api/v1/swagger/paths/erm_default_usage_reports.yaml b/api/v1/swagger/paths/erm_default_usage_reports.yaml
index aa37c409ab5..51199e626ec 100644
--- a/api/v1/swagger/paths/erm_default_usage_reports.yaml
+++ b/api/v1/swagger/paths/erm_default_usage_reports.yaml
@@ -37,8 +37,11 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_default_usage_report"
           type: array
-      400:
-        description: Bad request
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -82,7 +85,7 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_default_usage_report"
       400:
-        description: Bad parameter
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -132,8 +135,8 @@
     responses:
       204:
         description: default_usage_report deleted
-      400:
-        description: default_usage_report deletion failed
+      "400":
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -164,4 +167,4 @@
           $ref: "../swagger.yaml#/definitions/error"
     x-koha-authorization:
       permissions:
-        erm: 1
\ No newline at end of file
+        erm: 1
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 1d2f3db4ced..895c1acf05f 100644
--- a/api/v1/swagger/paths/erm_eholdings_packages.yaml
+++ b/api/v1/swagger/paths/erm_eholdings_packages.yaml
@@ -80,8 +80,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:
@@ -130,7 +133,7 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_eholdings_package"
       400:
-        description: Bad parameter
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -197,6 +200,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:
@@ -263,7 +270,7 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_eholdings_package"
       400:
-        description: Bad parameter
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -310,7 +317,7 @@
       204:
         description: package deleted
       400:
-        description: package deletion failed
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -378,6 +385,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 772554fe8b1..d0af99fc0cf 100644
--- a/api/v1/swagger/paths/erm_eholdings_packages_resources.yaml
+++ b/api/v1/swagger/paths/erm_eholdings_packages_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:
diff --git a/api/v1/swagger/paths/erm_eholdings_resources.yaml b/api/v1/swagger/paths/erm_eholdings_resources.yaml
index 1374a20471a..eb2aa6ae314 100644
--- a/api/v1/swagger/paths/erm_eholdings_resources.yaml
+++ b/api/v1/swagger/paths/erm_eholdings_resources.yaml
@@ -57,8 +57,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:
@@ -112,6 +115,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:
@@ -173,6 +180,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 7cc31159f5c..87e037b5b3a 100644
--- a/api/v1/swagger/paths/erm_eholdings_titles.yaml
+++ b/api/v1/swagger/paths/erm_eholdings_titles.yaml
@@ -167,8 +167,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:
@@ -217,7 +220,7 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_eholdings_title"
       400:
-        description: Bad parameter
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -282,6 +285,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:
@@ -348,7 +355,7 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_eholdings_title"
       400:
-        description: Bad parameter
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -395,7 +402,7 @@
       204:
         description: title deleted
       400:
-        description: title deletion failed
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -461,7 +468,7 @@
               type: string
           additionalProperties: false
       400:
-        description: Bad parameter
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -537,7 +544,7 @@
               type: object
           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 1b30c6a05ba..bcef4b47767 100644
--- a/api/v1/swagger/paths/erm_eholdings_titles_resources.yaml
+++ b/api/v1/swagger/paths/erm_eholdings_titles_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:
diff --git a/api/v1/swagger/paths/erm_licenses.yaml b/api/v1/swagger/paths/erm_licenses.yaml
index 6dc6c4ebe69..129ce470481 100644
--- a/api/v1/swagger/paths/erm_licenses.yaml
+++ b/api/v1/swagger/paths/erm_licenses.yaml
@@ -66,8 +66,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:
@@ -111,7 +114,7 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_license"
       400:
-        description: Bad parameter
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -177,6 +180,10 @@
         schema:
           items:
             $ref: "../swagger.yaml#/definitions/erm_license"
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       401:
         description: authentication required
         schema:
@@ -238,7 +245,7 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_license"
       400:
-        description: bad parameter
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -284,7 +291,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_sushi_services.yaml b/api/v1/swagger/paths/erm_sushi_services.yaml
index 2fd0377565a..72ba993cc86 100644
--- a/api/v1/swagger/paths/erm_sushi_services.yaml
+++ b/api/v1/swagger/paths/erm_sushi_services.yaml
@@ -21,8 +21,11 @@
         schema:
           items:
             $ref: "../swagger.yaml#/definitions/erm_sushi_service"
-      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_usage_data_providers.yaml b/api/v1/swagger/paths/erm_usage_data_providers.yaml
index 9fd3296bf3e..238bf37b3f3 100644
--- a/api/v1/swagger/paths/erm_usage_data_providers.yaml
+++ b/api/v1/swagger/paths/erm_usage_data_providers.yaml
@@ -107,8 +107,11 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_usage_data_provider"
           type: array
-      400:
-        description: Bad request
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -152,7 +155,7 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_usage_data_provider"
       400:
-        description: Bad parameter
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -216,6 +219,10 @@
         schema:
           items:
             $ref: "../swagger.yaml#/definitions/erm_usage_data_provider"
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       401:
         description: authentication required
         schema:
@@ -273,8 +280,8 @@
         schema:
           items:
             $ref: "../swagger.yaml#/definitions/erm_usage_data_provider"
-      400:
-        description: bad parameter
+      "400":
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -319,8 +326,8 @@
     responses:
       204:
         description: usage_data_provider deleted
-      400:
-        description: usage_data_provider deletion failed
+      "400":
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -491,4 +498,4 @@
           $ref: "../swagger.yaml#/definitions/error"
     x-koha-authorization:
       permissions:
-        erm: 1
\ No newline at end of file
+        erm: 1
diff --git a/api/v1/swagger/paths/erm_usage_databases.yaml b/api/v1/swagger/paths/erm_usage_databases.yaml
index adef38cd7cc..2717de9110f 100644
--- a/api/v1/swagger/paths/erm_usage_databases.yaml
+++ b/api/v1/swagger/paths/erm_usage_databases.yaml
@@ -64,8 +64,11 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_usage_database"
           type: array
-      400:
-        description: Bad request
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -84,4 +87,4 @@
           $ref: "../swagger.yaml#/definitions/error"
     x-koha-authorization:
       permissions:
-        erm: 1
\ No newline at end of file
+        erm: 1
diff --git a/api/v1/swagger/paths/erm_usage_items.yaml b/api/v1/swagger/paths/erm_usage_items.yaml
index 78a0fddb6fb..1cecbba3a57 100644
--- a/api/v1/swagger/paths/erm_usage_items.yaml
+++ b/api/v1/swagger/paths/erm_usage_items.yaml
@@ -59,8 +59,11 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_usage_item"
           type: array
-      400:
-        description: Bad request
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -79,4 +82,4 @@
           $ref: "../swagger.yaml#/definitions/error"
     x-koha-authorization:
       permissions:
-        erm: 1
\ No newline at end of file
+        erm: 1
diff --git a/api/v1/swagger/paths/erm_usage_platforms.yaml b/api/v1/swagger/paths/erm_usage_platforms.yaml
index ad7f81dc70d..0c83000a543 100644
--- a/api/v1/swagger/paths/erm_usage_platforms.yaml
+++ b/api/v1/swagger/paths/erm_usage_platforms.yaml
@@ -49,8 +49,11 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_usage_platform"
           type: array
-      400:
-        description: Bad request
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -69,4 +72,4 @@
           $ref: "../swagger.yaml#/definitions/error"
     x-koha-authorization:
       permissions:
-        erm: 1
\ No newline at end of file
+        erm: 1
diff --git a/api/v1/swagger/paths/erm_usage_titles.yaml b/api/v1/swagger/paths/erm_usage_titles.yaml
index 246c6147d4f..a6c035c904a 100644
--- a/api/v1/swagger/paths/erm_usage_titles.yaml
+++ b/api/v1/swagger/paths/erm_usage_titles.yaml
@@ -89,8 +89,11 @@
           items:
             $ref: "../swagger.yaml#/definitions/erm_usage_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:
diff --git a/api/v1/swagger/paths/erm_users.yaml b/api/v1/swagger/paths/erm_users.yaml
index ad559198de7..654bbefa8be 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/extended_attribute_types.yaml b/api/v1/swagger/paths/extended_attribute_types.yaml
index f20eb2ff585..758703a3c06 100644
--- a/api/v1/swagger/paths/extended_attribute_types.yaml
+++ b/api/v1/swagger/paths/extended_attribute_types.yaml
@@ -33,8 +33,11 @@
           items:
             $ref: "../swagger.yaml#/definitions/extended_attribute_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/holds.yaml b/api/v1/swagger/paths/holds.yaml
index 6458ff72ef3..b75ad24e508 100644
--- a/api/v1/swagger/paths/holds.yaml
+++ b/api/v1/swagger/paths/holds.yaml
@@ -112,6 +112,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:
@@ -224,7 +231,7 @@
         schema:
           $ref: "../swagger.yaml#/definitions/hold"
       "400":
-        description: Missing or wrong parameters
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -291,7 +298,7 @@
         schema:
           $ref: "../swagger.yaml#/definitions/hold"
       "400":
-        description: Missing or wrong parameters
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -359,7 +366,7 @@
         schema:
           $ref: "../swagger.yaml#/definitions/hold"
       "400":
-        description: Missing or wrong parameters
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -413,6 +420,10 @@
         description: Hold request recorded
       "204":
         description: Hold deleted
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -461,6 +472,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:
@@ -520,7 +535,7 @@
       "201":
         description: Hold suspended
       "400":
-        description: Missing or wrong parameters
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -565,7 +580,7 @@
       "204":
         description: Hold resumed
       "400":
-        description: Missing or wrong parameters
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -630,7 +645,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":
@@ -693,7 +711,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 52ff93dcb62..b54b06ba01b 100644
--- a/api/v1/swagger/paths/ill_backends.yaml
+++ b/api/v1/swagger/paths/ill_backends.yaml
@@ -24,6 +24,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:
@@ -80,6 +84,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:
@@ -105,4 +113,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_batches.yaml b/api/v1/swagger/paths/ill_batches.yaml
index d7ea3a0b5cd..6fd3a678289 100644
--- a/api/v1/swagger/paths/ill_batches.yaml
+++ b/api/v1/swagger/paths/ill_batches.yaml
@@ -35,6 +35,13 @@
         description: A list of ILL batches
         schema:
           $ref: "../swagger.yaml#/definitions/ill_batches"
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -170,6 +177,13 @@
         description: An ILL batch
         schema:
           $ref: "../swagger.yaml#/definitions/ill_batch"
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -264,6 +278,10 @@
         description: ILL batch 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/ill_batchstatuses.yaml b/api/v1/swagger/paths/ill_batchstatuses.yaml
index 87aabdd536b..cf006352f5b 100644
--- a/api/v1/swagger/paths/ill_batchstatuses.yaml
+++ b/api/v1/swagger/paths/ill_batchstatuses.yaml
@@ -14,6 +14,10 @@
         description: A list of ILL batch statuses
         schema:
           $ref: "../swagger.yaml#/definitions/ill_batchstatuses"
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -110,6 +114,10 @@
         description: An ILL batch status
         schema:
           $ref: "../swagger.yaml#/definitions/ill_batchstatus"
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -204,6 +212,10 @@
         description: ILL batch status 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/ill_requests.yaml b/api/v1/swagger/paths/ill_requests.yaml
index b021505850a..7927a56629a 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 958b486de66..513c0c7a9d5 100644
--- a/api/v1/swagger/paths/import_batch_profiles.yaml
+++ b/api/v1/swagger/paths/import_batch_profiles.yaml
@@ -28,6 +28,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:
@@ -128,7 +135,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":
@@ -237,7 +244,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":
@@ -279,6 +286,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 3f4677a9a35..62209a4eda7 100644
--- a/api/v1/swagger/paths/items.yaml
+++ b/api/v1/swagger/paths/items.yaml
@@ -41,6 +41,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:
@@ -92,7 +99,7 @@
         schema:
           $ref: "../swagger.yaml#/definitions/item"
       "400":
-        description: Missing or wrong parameters
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "404":
@@ -129,7 +136,7 @@
       "204":
         description: Deleted item
       "400":
-        description: Missing or wrong parameters
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "403":
@@ -191,7 +198,7 @@
           items:
             $ref: "../swagger.yaml#/definitions/item"
       "400":
-        description: Bad parameter
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -265,6 +272,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:
@@ -306,7 +320,7 @@
       "204":
         description: Bundle link deleted
       "400":
-        description: Bad parameter
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "409":
@@ -363,9 +377,12 @@
           items:
             $ref: ../swagger.yaml#/definitions/booking
       "400":
-        description: Missing or wrong parameters
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
         schema:
-          $ref: ../swagger.yaml#/definitions/error
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -422,7 +439,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":
@@ -493,6 +513,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 8fe7e04841f..7edd87dad22 100644
--- a/api/v1/swagger/paths/jobs.yaml
+++ b/api/v1/swagger/paths/jobs.yaml
@@ -28,6 +28,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:
@@ -62,6 +69,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 f7cda2d2e18..1f06fd4cea9 100644
--- a/api/v1/swagger/paths/libraries.yaml
+++ b/api/v1/swagger/paths/libraries.yaml
@@ -116,6 +116,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:
@@ -209,6 +216,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:
@@ -284,6 +295,10 @@
         description: Library deleted
         schema:
           type: string
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -335,6 +350,13 @@
           type: array
           items:
             $ref: "../swagger.yaml#/definitions/desk"
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       404:
         description: Resource not found
         schema:
@@ -378,6 +400,13 @@
           type: array
           items:
             $ref: "../swagger.yaml#/definitions/cash_register"
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       404:
         description: Resource not found
         schema:
@@ -420,6 +449,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:
@@ -445,6 +481,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/patron_categories.yaml b/api/v1/swagger/paths/patron_categories.yaml
index 85f57872e80..98d261e0705 100644
--- a/api/v1/swagger/paths/patron_categories.yaml
+++ b/api/v1/swagger/paths/patron_categories.yaml
@@ -23,6 +23,13 @@
           type: array
           items:
             $ref: "../swagger.yaml#/definitions/patron_category"
+      "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/patrons.yaml b/api/v1/swagger/paths/patrons.yaml
index 3cddaf5eedd..cf05d748d8b 100644
--- a/api/v1/swagger/paths/patrons.yaml
+++ b/api/v1/swagger/paths/patrons.yaml
@@ -372,6 +372,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:
@@ -430,7 +437,7 @@
             $ref: "../swagger.yaml#/definitions/patron"
       "400":
         description: |
-          Bad parameter. Possible `error_code` attribute values:
+          Bad request. Possible `error_code` attribute values:
 
             * `invalid_attribute_type`
             * `attribute_not_unique`
@@ -495,6 +502,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:
@@ -558,7 +569,7 @@
             $ref: "../swagger.yaml#/definitions/patron"
       "400":
         description: |
-          Bad parameter. Possible `error_code` attribute values:
+          Bad request. Possible `error_code` attribute values:
 
             * `invalid_attribute_type`
             * `attribute_not_unique`
@@ -606,7 +617,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 eaf96e91071..1ebdf8b8830 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:
@@ -66,6 +70,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:
@@ -103,6 +114,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:
@@ -153,6 +168,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:
@@ -195,7 +217,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_checkouts.yaml b/api/v1/swagger/paths/patrons_checkouts.yaml
index b5d35634267..4a0b64d77df 100644
--- a/api/v1/swagger/paths/patrons_checkouts.yaml
+++ b/api/v1/swagger/paths/patrons_checkouts.yaml
@@ -34,6 +34,13 @@
           type: array
           items:
             $ref: "../swagger.yaml#/definitions/checkout"
+      "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/patrons_extended_attributes.yaml b/api/v1/swagger/paths/patrons_extended_attributes.yaml
index 3d0ffc561c0..18d33c10c11 100644
--- a/api/v1/swagger/paths/patrons_extended_attributes.yaml
+++ b/api/v1/swagger/paths/patrons_extended_attributes.yaml
@@ -24,6 +24,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:
@@ -72,7 +79,7 @@
         schema:
           $ref: "../swagger.yaml#/definitions/patron_extended_attribute"
       "400":
-        description: Bad parameter
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -131,7 +138,7 @@
           items:
             $ref: "../swagger.yaml#/definitions/patron_extended_attribute"
       "400":
-        description: Bad parameters
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -198,7 +205,7 @@
         schema:
           $ref: "../swagger.yaml#/definitions/patron_extended_attribute"
       "400":
-        description: Bad parameter
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -249,6 +256,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 c8a4750b917..1915f427343 100644
--- a/api/v1/swagger/paths/patrons_holds.yaml
+++ b/api/v1/swagger/paths/patrons_holds.yaml
@@ -43,6 +43,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/patrons_recalls.yaml b/api/v1/swagger/paths/patrons_recalls.yaml
index c4b2d994da6..f99d73eafcd 100644
--- a/api/v1/swagger/paths/patrons_recalls.yaml
+++ b/api/v1/swagger/paths/patrons_recalls.yaml
@@ -24,6 +24,13 @@
           type: array
           items:
             $ref: "../swagger.yaml#/definitions/recall"
+      "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/preservation_processings.yaml b/api/v1/swagger/paths/preservation_processings.yaml
index eac8f25955d..6c66d122a03 100644
--- a/api/v1/swagger/paths/preservation_processings.yaml
+++ b/api/v1/swagger/paths/preservation_processings.yaml
@@ -32,8 +32,11 @@
           items:
             $ref: "../swagger.yaml#/definitions/preservation_processing"
           type: array
-      400:
-        description: Bad request
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -76,8 +79,8 @@
         schema:
           items:
             $ref: "../swagger.yaml#/definitions/preservation_processing"
-      400:
-        description: Bad parameter
+      "400":
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -140,6 +143,10 @@
         schema:
           items:
             $ref: "../swagger.yaml#/definitions/preservation_processing"
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       401:
         description: Authentication required
         schema:
@@ -190,8 +197,8 @@
         schema:
           items:
             $ref: "../swagger.yaml#/definitions/preservation_processing"
-      400:
-        description: Bad parameter
+      "400":
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -236,8 +243,8 @@
     responses:
       204:
         description: processing deleted
-      400:
-        description: processing deletion failed
+      "400":
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
diff --git a/api/v1/swagger/paths/preservation_trains.yaml b/api/v1/swagger/paths/preservation_trains.yaml
index 9644581fd7c..76cf7250bf9 100644
--- a/api/v1/swagger/paths/preservation_trains.yaml
+++ b/api/v1/swagger/paths/preservation_trains.yaml
@@ -62,8 +62,11 @@
           items:
             $ref: "../swagger.yaml#/definitions/preservation_train"
           type: array
-      400:
-        description: Bad request
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -107,8 +110,8 @@
         schema:
           items:
             $ref: "../swagger.yaml#/definitions/preservation_train"
-      400:
-        description: Bad parameter
+      "400":
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -178,6 +181,10 @@
         schema:
           items:
             $ref: "../swagger.yaml#/definitions/preservation_train"
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       401:
         description: Authentication required
         schema:
@@ -228,8 +235,8 @@
         schema:
           items:
             $ref: "../swagger.yaml#/definitions/preservation_train"
-      400:
-        description: Bad parameter
+      "400":
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -275,8 +282,8 @@
     responses:
       204:
         description: Train deleted
-      400:
-        description: Train deletion failed
+      "400":
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -333,8 +340,8 @@
         description: A successfully added item
         schema:
           $ref: "../swagger.yaml#/definitions/preservation_train_item"
-      400:
-        description: Bad parameter
+      "400":
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -399,8 +406,8 @@
           type: array
           items:
             type: object
-      400:
-        description: Bad parameter
+      "400":
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -472,8 +479,8 @@
         description: A successfully updated item
         schema:
           $ref: "../swagger.yaml#/definitions/preservation_train_item"
-      400:
-        description: Bad parameter
+      "400":
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       403:
@@ -521,7 +528,7 @@
       "204":
         description: Item removed
       "400":
-        description: Item removal failed
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -578,6 +585,10 @@
         description: An item in train
         schema:
           $ref: "../swagger.yaml#/definitions/preservation_train_item"
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       401:
         description: Authentication required
         schema:
@@ -635,8 +646,8 @@
         description: A successfully copied item
         schema:
           $ref: "../swagger.yaml#/definitions/preservation_train_item"
-      400:
-        description: Bad parameter
+      "400":
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
diff --git a/api/v1/swagger/paths/preservation_waiting_list.yaml b/api/v1/swagger/paths/preservation_waiting_list.yaml
index 26f1ef65486..ee5074288b6 100644
--- a/api/v1/swagger/paths/preservation_waiting_list.yaml
+++ b/api/v1/swagger/paths/preservation_waiting_list.yaml
@@ -41,7 +41,10 @@
           items:
             $ref: "../swagger.yaml#/definitions/item"
       "400":
-        description: Bad parameter
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -92,8 +95,8 @@
           type: array
           items:
             type: object
-      400:
-        description: Bad parameter
+      "400":
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       401:
@@ -145,7 +148,7 @@
       "204":
         description: Item removed
       "400":
-        description: Item removal failed
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
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/public_patrons.yaml b/api/v1/swagger/paths/public_patrons.yaml
index cda6d2a342a..2f2526e8273 100644
--- a/api/v1/swagger/paths/public_patrons.yaml
+++ b/api/v1/swagger/paths/public_patrons.yaml
@@ -91,7 +91,7 @@
         schema:
           $ref: "../swagger.yaml#/definitions/checkout"
       "400":
-        description: Missing or wrong parameters
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
diff --git a/api/v1/swagger/paths/quotes.yaml b/api/v1/swagger/paths/quotes.yaml
index 901b7af9337..c502fe3722c 100644
--- a/api/v1/swagger/paths/quotes.yaml
+++ b/api/v1/swagger/paths/quotes.yaml
@@ -43,6 +43,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:
@@ -81,6 +88,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:
@@ -119,6 +130,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:
@@ -158,6 +173,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:
@@ -197,6 +216,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/record_sources.yaml b/api/v1/swagger/paths/record_sources.yaml
index c1b1c182d8e..1e3da462733 100644
--- a/api/v1/swagger/paths/record_sources.yaml
+++ b/api/v1/swagger/paths/record_sources.yaml
@@ -25,7 +25,10 @@
           items:
             $ref: "../swagger.yaml#/definitions/record_source"
       "400":
-        description: Missing or wrong parameters
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -73,7 +76,7 @@
         schema:
           $ref: "../swagger.yaml#/definitions/record_source"
       "400":
-        description: Missing or wrong parameters
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -117,7 +120,7 @@
         schema:
           $ref: "../swagger.yaml#/definitions/record_source"
       "400":
-        description: Missing or wrong parameters
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -170,7 +173,7 @@
         schema:
           $ref: "../swagger.yaml#/definitions/record_source"
       "400":
-        description: Missing or wrong parameters
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
@@ -215,7 +218,7 @@
       "204":
         description: Deleted
       "400":
-        description: Missing or wrong parameters
+        description: Bad request
         schema:
           $ref: "../swagger.yaml#/definitions/error"
       "401":
diff --git a/api/v1/swagger/paths/rotas.yaml b/api/v1/swagger/paths/rotas.yaml
index 69c079afc75..da34d34587e 100644
--- a/api/v1/swagger/paths/rotas.yaml
+++ b/api/v1/swagger/paths/rotas.yaml
@@ -23,6 +23,13 @@
           type: array
           items:
             $ref: "../swagger.yaml#/definitions/rota"
+      "400":
+        description: |
+          Bad request. Possible `error_code` attribute values:
+
+            * `invalid_query`
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "403":
         description: Access forbidden
         schema:
@@ -61,6 +68,10 @@
         description: Rota added
         schema:
           $ref: "../swagger.yaml#/definitions/rota"
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -99,6 +110,10 @@
         description: A rota
         schema:
           $ref: "../swagger.yaml#/definitions/rota"
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "404":
         description: Rota not found
         schema:
@@ -138,6 +153,10 @@
         description: A rota
         schema:
           $ref: "../swagger.yaml#/definitions/rota"
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -174,6 +193,10 @@
     responses:
       "204":
         description: Rota deleted
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
diff --git a/api/v1/swagger/paths/search_filters.yaml b/api/v1/swagger/paths/search_filters.yaml
index 1948ad86af2..02224e618e5 100644
--- a/api/v1/swagger/paths/search_filters.yaml
+++ b/api/v1/swagger/paths/search_filters.yaml
@@ -23,6 +23,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:
@@ -58,6 +65,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:
@@ -97,6 +108,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:
@@ -137,6 +152,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:
@@ -175,6 +194,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 94f9a3b529e..a76c382f226 100644
--- a/api/v1/swagger/paths/suggestions.yaml
+++ b/api/v1/swagger/paths/suggestions.yaml
@@ -24,6 +24,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:
@@ -121,6 +128,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:
@@ -210,6 +221,10 @@
         description: Suggestion deleted
         schema:
           type: string
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -271,6 +286,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 a76239c66f4..c3010dfafa6 100644
--- a/api/v1/swagger/paths/tickets.yaml
+++ b/api/v1/swagger/paths/tickets.yaml
@@ -38,6 +38,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:
@@ -76,6 +83,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:
@@ -114,6 +125,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:
@@ -153,6 +171,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:
@@ -189,6 +211,10 @@
     responses:
       "204":
         description: Ticket deleted
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -249,6 +275,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:
@@ -292,6 +325,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:
@@ -336,6 +373,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 e6f60186028..74ad2c8b6a8 100644
--- a/api/v1/swagger/paths/transfer_limits.yaml
+++ b/api/v1/swagger/paths/transfer_limits.yaml
@@ -44,7 +44,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":
@@ -138,6 +141,10 @@
         description: Transfer limit deleted
         schema:
           type: string
+      "400":
+        description: Bad request
+        schema:
+          $ref: "../swagger.yaml#/definitions/error"
       "401":
         description: Authentication required
         schema:
@@ -313,6 +320,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 8ffa0ec5c0b..6dd35af3b2d 100755
--- a/xt/api.t
+++ b/xt/api.t
@@ -14,7 +14,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 4;
+use Test::More tests => 5;
 
 use Test::Mojo;
 use Data::Dumper;
@@ -127,3 +127,46 @@ subtest 'tags tests' => sub {
         print STDERR "$error\n";
     }
 };
+
+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 eq '#/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