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>
This commit is contained in:
Tomas Cohen Arazi 2020-04-02 18:40:49 -03:00 committed by Martin Renvoize
parent b33d69684f
commit 0bb0b6c7b4
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
9 changed files with 22 additions and 28 deletions

View File

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

View File

@ -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($_);

View File

@ -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($_);

View File

@ -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) {

View File

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

View File

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

View File

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

View File

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

View File

@ -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",