Bug 28369: Set additionalProperties: false and fix things

This patch performs a cleanup on the holds routes:
- It adds additionalProperties: false to all missing routes
- It syncs the spec with the guidelines
- additionalProperties: false highlighted some attributes read in the
  controlled weren't declared on the spec, adding them
- PUT /holds/:hold_id is moved to PATCH, as it makes more sense and
  gathered opinions lean towards that

To test:
1. Apply the tests patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/holds.t
=> FAIL: Lots of things are wrong with the API
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Tomas Cohen Arazi 2021-05-18 09:06:45 -03:00 committed by Jonathan Druart
parent cfe3e013a2
commit a554b5a545
2 changed files with 23 additions and 9 deletions

View File

@ -278,8 +278,8 @@ sub edit {
);
}
$pickup_library_id //= $hold->branchcode;
my $priority = $body->{priority} // $hold->priority;
$pickup_library_id //= $hold->branchcode;
my $priority = $body->{priority} // $hold->priority;
# suspended_until can also be set to undef
my $suspended_until = exists $body->{suspended_until} ? $body->{suspended_until} : $hold->suspend_until;

View File

@ -8,7 +8,7 @@
{
"name": "hold_id",
"in": "query",
"description": "Internal reserve identifier",
"description": "Internal hold identifier",
"type": "integer"
},
{
@ -120,6 +120,15 @@
},
{
"$ref": "../parameters.json#/per_page"
},
{
"$ref": "../parameters.json#/q_param"
},
{
"$ref": "../parameters.json#/q_body"
},
{
"$ref": "../parameters.json#/q_header"
}
],
"produces": ["application/json"],
@ -188,6 +197,11 @@
"description": "Internal biblio identifier",
"type": [ "integer", "null" ]
},
"hold_date": {
"description": "The date the hold was placed",
"type": [ "string", "null" ],
"format": "date"
},
"item_id": {
"description": "Internal item identifier",
"type": [ "integer", "null" ]
@ -280,7 +294,7 @@
}
},
"/holds/{hold_id}": {
"put": {
"patch": {
"x-mojo-to": "Holds#edit",
"operationId": "editHold",
"tags": ["holds"],
@ -299,14 +313,14 @@
"type": "integer",
"minimum": 1
},
"branchcode": {
"description": "Pickup location",
"pickup_library_id": {
"description": "Internal library identifier for the pickup library",
"type": "string"
},
"suspend_until": {
"description": "Suspend until",
"suspended_until": {
"description": "Date until which the hold has been suspended",
"type": "string",
"format": "date"
"format": "date-time"
}
},
"additionalProperties": false