Browse Source

Bug 25048: Make successful resource deletion return 204

This patch adapts the spec and the controllers so existing routes return
204 and an empty response body when a successful deletion happens.

Right now we have a coding guideline but haven't adapted the existing
routes.

To test:
1. Apply the regression tests patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/*.t
=> FAIL: Some tests fail
3. Apply this patch
4. Repeat 2.
=> SUCCESS: Tests pass!
5. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
20.05.x
Tomas Cohen Arazi 2 years ago
committed by Martin Renvoize
parent
commit
0bb0b6c7b4
Signed by: martin.renvoize GPG Key ID: 422B469130441A0F
  1. 2
      Koha/REST/V1/Acquisitions/Vendors.pm
  2. 5
      Koha/REST/V1/Cities.pm
  3. 5
      Koha/REST/V1/Holds.pm
  4. 5
      Koha/REST/V1/Patrons.pm
  5. 5
      api/v1/swagger/paths/acquisitions_orders.json
  6. 7
      api/v1/swagger/paths/acquisitions_vendors.json
  7. 7
      api/v1/swagger/paths/cities.json
  8. 7
      api/v1/swagger/paths/holds.json
  9. 7
      api/v1/swagger/paths/patrons.json

2
Koha/REST/V1/Acquisitions/Vendors.pm

@ -159,7 +159,7 @@ sub delete {
$vendor->delete;
return $c->render(
status => 200,
status => 204,
openapi => q{}
);
}

5
Koha/REST/V1/Cities.pm

@ -126,7 +126,10 @@ sub delete {
return try {
$city->delete;
return $c->render( status => 200, openapi => "" );
return $c->render(
status => 204,
openapi => q{}
);
}
catch {
$c->unhandled_exception($_);

5
Koha/REST/V1/Holds.pm

@ -262,7 +262,10 @@ sub delete {
return try {
$hold->cancel;
return $c->render( status => 200, openapi => {} );
return $c->render(
status => 204,
openapi => q{}
);
}
catch {
$c->unhandled_exception($_);

5
Koha/REST/V1/Patrons.pm

@ -279,7 +279,10 @@ sub delete {
# check if loans, reservations, debarrment, etc. before deletion!
$patron->delete;
return $c->render( status => 200, openapi => {} );
return $c->render(
status => 204,
openapi => q{}
);
}
catch {
unless ($patron) {

5
api/v1/swagger/paths/acquisitions_orders.json

@ -332,10 +332,7 @@
],
"responses": {
"204": {
"description": "Order deleted",
"schema": {
"type": "string"
}
"description": "Order deleted"
},
"401": {
"description": "Authentication required",

7
api/v1/swagger/paths/acquisitions_vendors.json

@ -264,11 +264,8 @@
"application/json"
],
"responses": {
"200": {
"description": "Vendor deleted",
"schema": {
"type": "string"
}
"204": {
"description": "Vendor deleted"
},
"401": {
"description": "Authentication required",

7
api/v1/swagger/paths/cities.json

@ -238,11 +238,8 @@
"application/json"
],
"responses": {
"200": {
"description": "City deleted",
"schema": {
"type": "string"
}
"204": {
"description": "City deleted"
},
"401": {
"description": "Authentication required",

7
api/v1/swagger/paths/holds.json

@ -355,11 +355,8 @@
],
"produces": ["application/json"],
"responses": {
"200": {
"description": "Successful deletion",
"schema": {
"type": "object"
}
"204": {
"description": "Hold deleted"
},
"401": {
"description": "Authentication required",

7
api/v1/swagger/paths/patrons.json

@ -669,11 +669,8 @@
}],
"produces": ["application/json"],
"responses": {
"200": {
"description": "Patron deleted successfully",
"schema": {
"type": "object"
}
"204": {
"description": "Patron deleted"
},
"400": {
"description": "Patron deletion failed",

Loading…
Cancel
Save