From 017506ce4ae015c3f7bdf31188691760fa298e72 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 6 May 2021 15:11:51 +0200 Subject: [PATCH] Bug 28272: Prevent api spec to accept extra parameters Some of our definition files are missing { additionalProperties: false } We must have it to make sure all properties are defined and prevent the spec to accept extra parameters (being more strict but also allowing to catch errors more easily) grep -rL additionalProperties api/v1/swagger/definitions/*.json Signed-off-by: Owen Leonard Signed-off-by: Tomas Cohen Arazi --- api/v1/swagger/definitions/account_line.json | 3 ++- api/v1/swagger/definitions/allows_renewal.json | 3 ++- api/v1/swagger/definitions/basket.json | 3 ++- api/v1/swagger/definitions/cashup.json | 3 ++- api/v1/swagger/definitions/checkout.json | 5 +++-- api/v1/swagger/definitions/checkouts.json | 3 ++- api/v1/swagger/definitions/club_hold.json | 5 +++-- api/v1/swagger/definitions/club_hold_patron_hold.json | 5 +++-- api/v1/swagger/definitions/club_hold_patron_holds.json | 5 +++-- api/v1/swagger/definitions/club_holds.json | 5 +++-- api/v1/swagger/definitions/error.json | 3 ++- api/v1/swagger/definitions/hold.json | 3 ++- api/v1/swagger/definitions/holds.json | 3 ++- api/v1/swagger/definitions/ill_backend.json | 3 ++- api/v1/swagger/definitions/ill_backends.json | 3 ++- api/v1/swagger/definitions/import_batch_profile.json | 5 +++-- api/v1/swagger/definitions/import_batch_profiles.json | 5 +++-- api/v1/swagger/definitions/patron_account_credit.json | 3 ++- api/v1/swagger/definitions/return_claim.json | 3 ++- 19 files changed, 45 insertions(+), 26 deletions(-) diff --git a/api/v1/swagger/definitions/account_line.json b/api/v1/swagger/definitions/account_line.json index 04c61551f81..ddf901602cc 100644 --- a/api/v1/swagger/definitions/account_line.json +++ b/api/v1/swagger/definitions/account_line.json @@ -97,5 +97,6 @@ ], "description": "Internal identifier for the library in which the transaction took place" } - } + }, + "additionalProperties": false } diff --git a/api/v1/swagger/definitions/allows_renewal.json b/api/v1/swagger/definitions/allows_renewal.json index 6db074b3fe4..9c40cedcdb0 100644 --- a/api/v1/swagger/definitions/allows_renewal.json +++ b/api/v1/swagger/definitions/allows_renewal.json @@ -17,5 +17,6 @@ "type": ["string", "null"], "description": "Description on false allows_renewal." } - } + }, + "additionalProperties": false } diff --git a/api/v1/swagger/definitions/basket.json b/api/v1/swagger/definitions/basket.json index e5b3b91931d..c5f0642d718 100644 --- a/api/v1/swagger/definitions/basket.json +++ b/api/v1/swagger/definitions/basket.json @@ -95,5 +95,6 @@ ], "description": "When items should be created for orders in this basket (Options: 'ordering', 'receiving', 'cataloguing'. Null means system wide config)" } - } + }, + "additionalProperties": false } diff --git a/api/v1/swagger/definitions/cashup.json b/api/v1/swagger/definitions/cashup.json index e643a9c4932..a4c5a426440 100644 --- a/api/v1/swagger/definitions/cashup.json +++ b/api/v1/swagger/definitions/cashup.json @@ -26,5 +26,6 @@ "type": "object", "description": "A summary of the cashup action" } - } + }, + "additionalProperties": false } diff --git a/api/v1/swagger/definitions/checkout.json b/api/v1/swagger/definitions/checkout.json index 6976d5da5f6..8540ea737ac 100644 --- a/api/v1/swagger/definitions/checkout.json +++ b/api/v1/swagger/definitions/checkout.json @@ -79,6 +79,7 @@ "null" ], "description": "The object representing the checkout issuer" - } -} + } + }, + "additionalProperties": false } diff --git a/api/v1/swagger/definitions/checkouts.json b/api/v1/swagger/definitions/checkouts.json index b6562f917af..bc3ff674e34 100644 --- a/api/v1/swagger/definitions/checkouts.json +++ b/api/v1/swagger/definitions/checkouts.json @@ -2,5 +2,6 @@ "type": "array", "items": { "$ref": "checkout.json" - } + }, + "additionalProperties": false } diff --git a/api/v1/swagger/definitions/club_hold.json b/api/v1/swagger/definitions/club_hold.json index 5a270bc5f1f..68cede65a1d 100644 --- a/api/v1/swagger/definitions/club_hold.json +++ b/api/v1/swagger/definitions/club_hold.json @@ -17,5 +17,6 @@ "type": ["string", "null"], "description": "Internal item identifier" } - } - } + }, + "additionalProperties": false +} diff --git a/api/v1/swagger/definitions/club_hold_patron_hold.json b/api/v1/swagger/definitions/club_hold_patron_hold.json index 1f338149c00..43b1097798e 100644 --- a/api/v1/swagger/definitions/club_hold_patron_hold.json +++ b/api/v1/swagger/definitions/club_hold_patron_hold.json @@ -26,5 +26,6 @@ "type": ["string", "null"], "description": "Generic error message" } - } - } + }, + "additionalProperties": false +} diff --git a/api/v1/swagger/definitions/club_hold_patron_holds.json b/api/v1/swagger/definitions/club_hold_patron_holds.json index ff7b6e506da..b2ae3569155 100644 --- a/api/v1/swagger/definitions/club_hold_patron_holds.json +++ b/api/v1/swagger/definitions/club_hold_patron_holds.json @@ -2,5 +2,6 @@ "type": "array", "items": { "$ref": "club_hold_patron_hold.json" - } -} \ No newline at end of file + }, + "additionalProperties": false +} diff --git a/api/v1/swagger/definitions/club_holds.json b/api/v1/swagger/definitions/club_holds.json index b484840f946..2de31639e0c 100644 --- a/api/v1/swagger/definitions/club_holds.json +++ b/api/v1/swagger/definitions/club_holds.json @@ -2,5 +2,6 @@ "type": "array", "items": { "$ref": "club_hold.json" - } -} \ No newline at end of file + }, + "additionalProperties": false +} diff --git a/api/v1/swagger/definitions/error.json b/api/v1/swagger/definitions/error.json index e43673f2174..b0fe4fc9929 100644 --- a/api/v1/swagger/definitions/error.json +++ b/api/v1/swagger/definitions/error.json @@ -5,5 +5,6 @@ "description": "Error message", "type": "string" } - } + }, + "additionalProperties": false } diff --git a/api/v1/swagger/definitions/hold.json b/api/v1/swagger/definitions/hold.json index 6a018e916fc..58f32343c88 100644 --- a/api/v1/swagger/definitions/hold.json +++ b/api/v1/swagger/definitions/hold.json @@ -83,5 +83,6 @@ "type": "boolean", "description": "If the hold is placed at item level" } - } + }, + "additionalProperties": false } diff --git a/api/v1/swagger/definitions/holds.json b/api/v1/swagger/definitions/holds.json index e55188592f2..b2ee4a6e778 100644 --- a/api/v1/swagger/definitions/holds.json +++ b/api/v1/swagger/definitions/holds.json @@ -2,5 +2,6 @@ "type": "array", "items": { "$ref": "hold.json" - } + }, + "additionalProperties": false } diff --git a/api/v1/swagger/definitions/ill_backend.json b/api/v1/swagger/definitions/ill_backend.json index f67dc47ea26..34199e0a3dd 100644 --- a/api/v1/swagger/definitions/ill_backend.json +++ b/api/v1/swagger/definitions/ill_backend.json @@ -9,5 +9,6 @@ "type": "object", "description": "List of capabilities" } - } + }, + "additionalProperties": false } diff --git a/api/v1/swagger/definitions/ill_backends.json b/api/v1/swagger/definitions/ill_backends.json index fc68c500e42..2cdd5c49179 100644 --- a/api/v1/swagger/definitions/ill_backends.json +++ b/api/v1/swagger/definitions/ill_backends.json @@ -2,5 +2,6 @@ "type": "array", "items": { "$ref": "ill_backend.json" - } + }, + "additionalProperties": false } diff --git a/api/v1/swagger/definitions/import_batch_profile.json b/api/v1/swagger/definitions/import_batch_profile.json index fde0393fdb0..98e3aa85c79 100644 --- a/api/v1/swagger/definitions/import_batch_profile.json +++ b/api/v1/swagger/definitions/import_batch_profile.json @@ -49,5 +49,6 @@ "description": "any comments added when the file was uploaded", "type": ["string", "null"] } - } -} \ No newline at end of file + }, + "additionalProperties": false +} diff --git a/api/v1/swagger/definitions/import_batch_profiles.json b/api/v1/swagger/definitions/import_batch_profiles.json index 4c2b17b2326..e02e5898fc9 100644 --- a/api/v1/swagger/definitions/import_batch_profiles.json +++ b/api/v1/swagger/definitions/import_batch_profiles.json @@ -2,5 +2,6 @@ "type": "array", "items": { "$ref": "import_batch_profile.json" - } - } \ No newline at end of file + }, + "additionalProperties": false +} diff --git a/api/v1/swagger/definitions/patron_account_credit.json b/api/v1/swagger/definitions/patron_account_credit.json index ba156fe9ffc..74ed408fefd 100644 --- a/api/v1/swagger/definitions/patron_account_credit.json +++ b/api/v1/swagger/definitions/patron_account_credit.json @@ -39,5 +39,6 @@ "description": "Internal note" } }, - "required": [ "amount" ] + "required": [ "amount" ], + "additionalProperties": false } diff --git a/api/v1/swagger/definitions/return_claim.json b/api/v1/swagger/definitions/return_claim.json index 62f2baec6e5..f23812a3731 100644 --- a/api/v1/swagger/definitions/return_claim.json +++ b/api/v1/swagger/definitions/return_claim.json @@ -89,5 +89,6 @@ ], "description": "patron id of librarian who resolved this claim" } - } + }, + "additionalProperties": false } -- 2.31.1