diff --git a/src/iam/router.py b/src/iam/router.py index b1b2dab..77c02e0 100644 --- a/src/iam/router.py +++ b/src/iam/router.py @@ -157,9 +157,56 @@ async def can_act_on_resource( status_code=status.HTTP_200_OK, response_model=IAMGetGroupPermissionsResponse, responses={ + status.HTTP_422_UNPROCESSABLE_CONTENT: { + "description": "Unprocessable content.", + "content": { + "application/json": { + "examples": { + "org_id": {"summary": "Invalid or missing org ID."}, + "oidc_claims": {"summary": "Invalid or missing OIDC claims."}, + } + } + }, + }, status.HTTP_401_UNAUTHORIZED: { - "description": "Group does not belong to this organisation" - } + "description": "Unauthorized", + "content": { + "application/json": { + "examples": { + "awaiting_approval": { + "summary": "Organisation has not yet been approved." + }, + "expired_token": {"summary": "User token has expired."}, + "oidc": {"summary": "Failed to verify OIDC claims."}, + } + } + }, + }, + status.HTTP_403_FORBIDDEN: { + "description": "Forbidden", + "content": { + "application/json": { + "examples": { + "not_root": {"summary": "Not authorised. Must be root user."}, + } + } + }, + }, + status.HTTP_404_NOT_FOUND: { + "description": "Not found", + "content": { + "application/json": { + "examples": { + "db_id": { + "summary": "User not found in db when checking claims." + }, + "user_model": {"summary": "User model not found in db."}, + "org_model": {"summary": "Org model not found in db."}, + "group_model": {"summary": "Group model not found in db."}, + } + } + }, + }, }, ) async def get_group_permissions( diff --git a/src/organisation/dependencies.py b/src/organisation/dependencies.py index 5ad9e0d..67150e5 100644 --- a/src/organisation/dependencies.py +++ b/src/organisation/dependencies.py @@ -58,7 +58,7 @@ def get_org_model_body( ) -> type[Org]: org_id: Optional[int] = getattr(request_model, "organisation_id", None) if org_id is None: - raise OrgNotFoundException + raise OrgNotFoundException() return get_org_model(db, request, org_id) diff --git a/src/organisation/router.py b/src/organisation/router.py index 99c10f6..eb74f0a 100644 --- a/src/organisation/router.py +++ b/src/organisation/router.py @@ -387,7 +387,29 @@ async def delete_organisation_by_id( "description": "Successfully deleted organisation." }, status.HTTP_422_UNPROCESSABLE_CONTENT: { - "description": "Org ID missing or invalid." + "description": "Unprocessable content.", + "content": { + "application/json": { + "examples": { + "org_id": {"summary": "Invalid or missing org ID."}, + "oidc_claims": {"summary": "Invalid or missing OIDC claims."}, + } + } + }, + }, + status.HTTP_401_UNAUTHORIZED: { + "description": "Unauthorized", + "content": { + "application/json": { + "examples": { + "awaiting_approval": { + "summary": "Organisation has not yet been approved." + }, + "expired_token": {"summary": "User token has expired."}, + "oidc": {"summary": "Failed to verify OIDC claims."}, + } + } + }, }, status.HTTP_403_FORBIDDEN: { "description": "Forbidden", @@ -402,6 +424,20 @@ async def delete_organisation_by_id( } }, }, + status.HTTP_404_NOT_FOUND: { + "description": "Not found", + "content": { + "application/json": { + "examples": { + "db_id": { + "summary": "User not found in db when checking claims." + }, + "user_model": {"summary": "User model not found in db."}, + "org_model": {"summary": "Org model not found in db."}, + } + } + }, + }, }, ) async def delete_preapproved_organisation_by_id( diff --git a/src/service/router.py b/src/service/router.py index bfd282e..ee0f0ad 100644 --- a/src/service/router.py +++ b/src/service/router.py @@ -46,7 +46,28 @@ router = APIRouter( response_model=ServiceGetServiceResponse, responses={ status.HTTP_200_OK: {"description": "Successful retrieval from database"}, - status.HTTP_401_UNAUTHORIZED: {"description": "Unauthorized"}, + status.HTTP_401_UNAUTHORIZED: { + "description": "Unauthorized", + "content": { + "application/json": { + "examples": { + "awaiting_approval": { + "summary": "Organisation has not yet been approved." + }, + } + } + }, + }, + status.HTTP_403_FORBIDDEN: { + "description": "Forbidden", + "content": { + "application/json": { + "examples": { + "not_root": {"summary": "Not authorised. Must be root user."}, + } + } + }, + }, }, ) async def get_all_services(