Skip to content

Commit 8315bf3

Browse files
committed
errors in API
1 parent 9925abb commit 8315bf3

File tree

2 files changed

+269
-3
lines changed

2 files changed

+269
-3
lines changed

api/specs/web-server/_trash.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@
88
from typing import Annotated
99

1010
from fastapi import APIRouter, Depends, status
11+
from models_library.rest_error import EnvelopedError
1112
from models_library.trash import RemoveQueryParams
1213
from simcore_service_webserver._meta import API_VTAG
1314
from simcore_service_webserver.folders._common.models import (
1415
FoldersPathParams,
1516
FolderTrashQueryParams,
1617
)
18+
from simcore_service_webserver.projects._common.exceptions_handlers import (
19+
_TO_HTTP_ERROR_MAP,
20+
)
1721
from simcore_service_webserver.projects._trash_rest import ProjectPathParams
1822
from simcore_service_webserver.workspaces._common.models import (
1923
WorkspacesPathParams,
@@ -23,6 +27,9 @@
2327
router = APIRouter(
2428
prefix=f"/{API_VTAG}",
2529
tags=["trash"],
30+
responses={
31+
i.status_code: {"model": EnvelopedError} for i in _TO_HTTP_ERROR_MAP.values()
32+
},
2633
)
2734

2835

@@ -42,11 +49,18 @@ def empty_trash():
4249
tags=_extra_tags,
4350
status_code=status.HTTP_204_NO_CONTENT,
4451
responses={
45-
status.HTTP_404_NOT_FOUND: {"description": "Not such a project"},
52+
status.HTTP_404_NOT_FOUND: {
53+
"description": "Not such a project",
54+
"model": EnvelopedError,
55+
},
4656
status.HTTP_409_CONFLICT: {
47-
"description": "Project is in use and cannot be trashed"
57+
"description": "Project is in use and cannot be trashed",
58+
"model": EnvelopedError,
59+
},
60+
status.HTTP_503_SERVICE_UNAVAILABLE: {
61+
"description": "Trash service error",
62+
"model": EnvelopedError,
4863
},
49-
status.HTTP_503_SERVICE_UNAVAILABLE: {"description": "Trash service error"},
5064
},
5165
)
5266
def trash_project(

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6360,6 +6360,48 @@ paths:
63606360
responses:
63616361
'204':
63626362
description: Successful Response
6363+
'403':
6364+
description: Forbidden
6365+
content:
6366+
application/json:
6367+
schema:
6368+
$ref: '#/components/schemas/EnvelopedError'
6369+
'404':
6370+
description: Not Found
6371+
content:
6372+
application/json:
6373+
schema:
6374+
$ref: '#/components/schemas/EnvelopedError'
6375+
'409':
6376+
description: Conflict
6377+
content:
6378+
application/json:
6379+
schema:
6380+
$ref: '#/components/schemas/EnvelopedError'
6381+
'422':
6382+
description: Unprocessable Entity
6383+
content:
6384+
application/json:
6385+
schema:
6386+
$ref: '#/components/schemas/EnvelopedError'
6387+
'400':
6388+
description: Bad Request
6389+
content:
6390+
application/json:
6391+
schema:
6392+
$ref: '#/components/schemas/EnvelopedError'
6393+
'402':
6394+
description: Payment Required
6395+
content:
6396+
application/json:
6397+
schema:
6398+
$ref: '#/components/schemas/EnvelopedError'
6399+
'503':
6400+
description: Service Unavailable
6401+
content:
6402+
application/json:
6403+
schema:
6404+
$ref: '#/components/schemas/EnvelopedError'
63636405
/v0/projects/{project_id}:trash:
63646406
post:
63656407
tags:
@@ -6385,12 +6427,48 @@ paths:
63856427
responses:
63866428
'204':
63876429
description: Successful Response
6430+
'403':
6431+
content:
6432+
application/json:
6433+
schema:
6434+
$ref: '#/components/schemas/EnvelopedError'
6435+
description: Forbidden
63886436
'404':
63896437
description: Not such a project
6438+
content:
6439+
application/json:
6440+
schema:
6441+
$ref: '#/components/schemas/EnvelopedError'
63906442
'409':
63916443
description: Project is in use and cannot be trashed
6444+
content:
6445+
application/json:
6446+
schema:
6447+
$ref: '#/components/schemas/EnvelopedError'
6448+
'422':
6449+
content:
6450+
application/json:
6451+
schema:
6452+
$ref: '#/components/schemas/EnvelopedError'
6453+
description: Unprocessable Entity
6454+
'400':
6455+
content:
6456+
application/json:
6457+
schema:
6458+
$ref: '#/components/schemas/EnvelopedError'
6459+
description: Bad Request
6460+
'402':
6461+
content:
6462+
application/json:
6463+
schema:
6464+
$ref: '#/components/schemas/EnvelopedError'
6465+
description: Payment Required
63926466
'503':
63936467
description: Trash service error
6468+
content:
6469+
application/json:
6470+
schema:
6471+
$ref: '#/components/schemas/EnvelopedError'
63946472
/v0/projects/{project_id}:untrash:
63956473
post:
63966474
tags:
@@ -6409,6 +6487,48 @@ paths:
64096487
responses:
64106488
'204':
64116489
description: Successful Response
6490+
'403':
6491+
content:
6492+
application/json:
6493+
schema:
6494+
$ref: '#/components/schemas/EnvelopedError'
6495+
description: Forbidden
6496+
'404':
6497+
content:
6498+
application/json:
6499+
schema:
6500+
$ref: '#/components/schemas/EnvelopedError'
6501+
description: Not Found
6502+
'409':
6503+
content:
6504+
application/json:
6505+
schema:
6506+
$ref: '#/components/schemas/EnvelopedError'
6507+
description: Conflict
6508+
'422':
6509+
content:
6510+
application/json:
6511+
schema:
6512+
$ref: '#/components/schemas/EnvelopedError'
6513+
description: Unprocessable Entity
6514+
'400':
6515+
content:
6516+
application/json:
6517+
schema:
6518+
$ref: '#/components/schemas/EnvelopedError'
6519+
description: Bad Request
6520+
'402':
6521+
content:
6522+
application/json:
6523+
schema:
6524+
$ref: '#/components/schemas/EnvelopedError'
6525+
description: Payment Required
6526+
'503':
6527+
content:
6528+
application/json:
6529+
schema:
6530+
$ref: '#/components/schemas/EnvelopedError'
6531+
description: Service Unavailable
64126532
/v0/folders/{folder_id}:trash:
64136533
post:
64146534
tags:
@@ -6435,11 +6555,35 @@ paths:
64356555
responses:
64366556
'204':
64376557
description: Successful Response
6558+
'403':
6559+
content:
6560+
application/json:
6561+
schema:
6562+
$ref: '#/components/schemas/EnvelopedError'
6563+
description: Forbidden
64386564
'404':
64396565
description: Not such a folder
64406566
'409':
64416567
description: One or more projects in the folder are in use and cannot be
64426568
trashed
6569+
'422':
6570+
content:
6571+
application/json:
6572+
schema:
6573+
$ref: '#/components/schemas/EnvelopedError'
6574+
description: Unprocessable Entity
6575+
'400':
6576+
content:
6577+
application/json:
6578+
schema:
6579+
$ref: '#/components/schemas/EnvelopedError'
6580+
description: Bad Request
6581+
'402':
6582+
content:
6583+
application/json:
6584+
schema:
6585+
$ref: '#/components/schemas/EnvelopedError'
6586+
description: Payment Required
64436587
'503':
64446588
description: Trash service error
64456589
/v0/folders/{folder_id}:untrash:
@@ -6461,6 +6605,48 @@ paths:
64616605
responses:
64626606
'204':
64636607
description: Successful Response
6608+
'403':
6609+
content:
6610+
application/json:
6611+
schema:
6612+
$ref: '#/components/schemas/EnvelopedError'
6613+
description: Forbidden
6614+
'404':
6615+
content:
6616+
application/json:
6617+
schema:
6618+
$ref: '#/components/schemas/EnvelopedError'
6619+
description: Not Found
6620+
'409':
6621+
content:
6622+
application/json:
6623+
schema:
6624+
$ref: '#/components/schemas/EnvelopedError'
6625+
description: Conflict
6626+
'422':
6627+
content:
6628+
application/json:
6629+
schema:
6630+
$ref: '#/components/schemas/EnvelopedError'
6631+
description: Unprocessable Entity
6632+
'400':
6633+
content:
6634+
application/json:
6635+
schema:
6636+
$ref: '#/components/schemas/EnvelopedError'
6637+
description: Bad Request
6638+
'402':
6639+
content:
6640+
application/json:
6641+
schema:
6642+
$ref: '#/components/schemas/EnvelopedError'
6643+
description: Payment Required
6644+
'503':
6645+
content:
6646+
application/json:
6647+
schema:
6648+
$ref: '#/components/schemas/EnvelopedError'
6649+
description: Service Unavailable
64646650
/v0/workspaces/{workspace_id}:trash:
64656651
post:
64666652
tags:
@@ -6487,11 +6673,35 @@ paths:
64876673
responses:
64886674
'204':
64896675
description: Successful Response
6676+
'403':
6677+
content:
6678+
application/json:
6679+
schema:
6680+
$ref: '#/components/schemas/EnvelopedError'
6681+
description: Forbidden
64906682
'404':
64916683
description: Not such a workspace
64926684
'409':
64936685
description: One or more projects in the workspace are in use and cannot
64946686
be trashed
6687+
'422':
6688+
content:
6689+
application/json:
6690+
schema:
6691+
$ref: '#/components/schemas/EnvelopedError'
6692+
description: Unprocessable Entity
6693+
'400':
6694+
content:
6695+
application/json:
6696+
schema:
6697+
$ref: '#/components/schemas/EnvelopedError'
6698+
description: Bad Request
6699+
'402':
6700+
content:
6701+
application/json:
6702+
schema:
6703+
$ref: '#/components/schemas/EnvelopedError'
6704+
description: Payment Required
64956705
'503':
64966706
description: Trash service error
64976707
/v0/workspaces/{workspace_id}:untrash:
@@ -6513,6 +6723,48 @@ paths:
65136723
responses:
65146724
'204':
65156725
description: Successful Response
6726+
'403':
6727+
content:
6728+
application/json:
6729+
schema:
6730+
$ref: '#/components/schemas/EnvelopedError'
6731+
description: Forbidden
6732+
'404':
6733+
content:
6734+
application/json:
6735+
schema:
6736+
$ref: '#/components/schemas/EnvelopedError'
6737+
description: Not Found
6738+
'409':
6739+
content:
6740+
application/json:
6741+
schema:
6742+
$ref: '#/components/schemas/EnvelopedError'
6743+
description: Conflict
6744+
'422':
6745+
content:
6746+
application/json:
6747+
schema:
6748+
$ref: '#/components/schemas/EnvelopedError'
6749+
description: Unprocessable Entity
6750+
'400':
6751+
content:
6752+
application/json:
6753+
schema:
6754+
$ref: '#/components/schemas/EnvelopedError'
6755+
description: Bad Request
6756+
'402':
6757+
content:
6758+
application/json:
6759+
schema:
6760+
$ref: '#/components/schemas/EnvelopedError'
6761+
description: Payment Required
6762+
'503':
6763+
content:
6764+
application/json:
6765+
schema:
6766+
$ref: '#/components/schemas/EnvelopedError'
6767+
description: Service Unavailable
65166768
/v0/workspaces:
65176769
post:
65186770
tags:

0 commit comments

Comments
 (0)