From 7aac9e7cc65b1a3ca4b994523c38918acc813a2d Mon Sep 17 00:00:00 2001 From: Artem Morozov Date: Mon, 22 May 2023 23:19:52 +0300 Subject: [PATCH 1/4] Print-errors update. --- print_service/routes/exc_handlers.py | 51 +++++++++++++++++----------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/print_service/routes/exc_handlers.py b/print_service/routes/exc_handlers.py index 63d286e..e8f9301 100644 --- a/print_service/routes/exc_handlers.py +++ b/print_service/routes/exc_handlers.py @@ -22,27 +22,33 @@ UserNotFound, ) from print_service.routes.base import app +from print_service.settings import get_settings + + +settings = get_settings() @app.exception_handler(TooLargeSize) async def too_large_size(req: starlette.requests.Request, exc: TooLargeSize): - return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}").dict(), status_code=413 - ) + payload = StatusResponseModel(status="Error", message=f"{exc}").dict() + payload['ru'] = f'Размер файла превышает максимально допустимый: {settings.MAX_SIZE}' + return JSONResponse(content=payload, status_code=413) @app.exception_handler(TooManyPages) async def too_many_pages(req: starlette.requests.Request, exc: TooManyPages): - return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}").dict(), status_code=413 - ) + payload = StatusResponseModel(status="Error", message=f"{exc}").dict() + payload[ + 'ru' + ] = f'Количество запрошенных страниц превышает допустимое число: {settings.MAX_PAGE_COUNT}' + return JSONResponse(content=payload, status_code=413) @app.exception_handler(InvalidPageRequest) async def invalid_format(req: starlette.requests.Request, exc: TooManyPages): - return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}").dict(), status_code=416 - ) + payload = StatusResponseModel(status="Error", message=f"{exc}").dict() + payload['ru'] = 'Количество запрошенных страниц превышает их количество в файле' + return JSONResponse(content=payload, status_code=416) @app.exception_handler(TerminalQRNotFound) @@ -77,9 +83,9 @@ async def student_duplicate(req: starlette.requests.Request, exc: UnionStudentDu @app.exception_handler(NotInUnion) async def not_in_union(req: starlette.requests.Request, exc: NotInUnion): - return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}").dict(), status_code=403 - ) + payload = StatusResponseModel(status="Error", message=f"{exc}").dict() + payload['ru'] = 'Отсутствует членство в профсоюзе' + return JSONResponse(content=payload, status_code=403) @app.exception_handler(PINGenerateError) @@ -91,8 +97,11 @@ async def generate_error(req: starlette.requests.Request, exc: PINGenerateError) @app.exception_handler(FileIsNotReceived) async def file_not_received(req: starlette.requests.Request, exc: FileIsNotReceived): + payload = StatusResponseModel(status="Error", message=f"{exc}").dict() + payload['ru'] = 'Файл не получен' return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}").dict(), status_code=400 + content=payload, + status_code=400, ) @@ -106,9 +115,9 @@ async def pin_not_found(req: starlette.requests.Request, exc: PINNotFound): @app.exception_handler(InvalidType) async def invalid_type(req: starlette.requests.Request, exc: InvalidType): - return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}").dict(), status_code=415 - ) + payload = StatusResponseModel(status="Error", message=f"{exc}").dict() + payload['ru'] = f'Неподдерживаемый формат файла. Допустимые: {settings.CONTENT_TYPES}' + return JSONResponse(content=payload, status_code=415) @app.exception_handler(AlreadyUploaded) @@ -120,9 +129,9 @@ async def already_upload(req: starlette.requests.Request, exc: AlreadyUploaded): @app.exception_handler(IsCorrupted) async def is_corrupted(req: starlette.requests.Request, exc: IsCorrupted): - return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}").dict(), status_code=415 - ) + payload = StatusResponseModel(status="Error", message=f"{exc}").dict() + payload['ru'] = 'Файл повреждён' + return JSONResponse(content=payload, status_code=415) @app.exception_handler(UnprocessableFileInstance) @@ -134,8 +143,10 @@ async def unprocessable_file_instance(req: starlette.requests.Request, exc: Unpr @app.exception_handler(FileNotFound) async def file_not_found(req: starlette.requests.Request, exc: FileNotFound): + payload = StatusResponseModel(status="Error", message=f"{exc.count} file(s) not found").dict() + payload['ru'] = 'Файл не найден' return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc.count} file(s) not found").dict(), + content=payload, status_code=404, ) From b62fbd769850cc4793227f57a833fce6045ddd3a Mon Sep 17 00:00:00 2001 From: Artem Morozov Date: Tue, 23 May 2023 00:03:44 +0300 Subject: [PATCH 2/4] Print-errors update. --- print_service/base.py | 1 + print_service/routes/exc_handlers.py | 113 ++++++++++++++++++--------- 2 files changed, 79 insertions(+), 35 deletions(-) diff --git a/print_service/base.py b/print_service/base.py index b600580..7df662f 100644 --- a/print_service/base.py +++ b/print_service/base.py @@ -15,3 +15,4 @@ class Config: class StatusResponseModel(Base): status: str message: str + ru: str diff --git a/print_service/routes/exc_handlers.py b/print_service/routes/exc_handlers.py index e8f9301..4b93b73 100644 --- a/print_service/routes/exc_handlers.py +++ b/print_service/routes/exc_handlers.py @@ -1,3 +1,4 @@ +import requests.models import starlette.requests from starlette.responses import JSONResponse @@ -30,31 +31,46 @@ @app.exception_handler(TooLargeSize) async def too_large_size(req: starlette.requests.Request, exc: TooLargeSize): - payload = StatusResponseModel(status="Error", message=f"{exc}").dict() - payload['ru'] = f'Размер файла превышает максимально допустимый: {settings.MAX_SIZE}' - return JSONResponse(content=payload, status_code=413) + return JSONResponse( + content=StatusResponseModel( + status="Error", + message=f"{exc}", + ru=f'Размер файла превышает максимально допустимый: {settings.MAX_SIZE}', + ).dict(), + status_code=413, + ) @app.exception_handler(TooManyPages) async def too_many_pages(req: starlette.requests.Request, exc: TooManyPages): - payload = StatusResponseModel(status="Error", message=f"{exc}").dict() - payload[ - 'ru' - ] = f'Количество запрошенных страниц превышает допустимое число: {settings.MAX_PAGE_COUNT}' - return JSONResponse(content=payload, status_code=413) + return JSONResponse( + content=StatusResponseModel( + status="Error", + message=f"{exc}", + ru=f'Количество запрошенных страниц превышает допустимое число: {settings.MAX_PAGE_COUNT}', + ).dict(), + status_code=413, + ) @app.exception_handler(InvalidPageRequest) async def invalid_format(req: starlette.requests.Request, exc: TooManyPages): - payload = StatusResponseModel(status="Error", message=f"{exc}").dict() - payload['ru'] = 'Количество запрошенных страниц превышает их количество в файле' - return JSONResponse(content=payload, status_code=416) + return JSONResponse( + content=StatusResponseModel( + status="Error", + message=f"{exc}", + ru='Количество запрошенных страниц превышает их количество в файле', + ).dict(), + status_code=416, + ) @app.exception_handler(TerminalQRNotFound) async def terminal_not_found_by_qr(req: starlette.requests.Request, exc: TerminalQRNotFound): return JSONResponse( - content=StatusResponseModel(status="Error", message=f"Terminal not found by QR").dict(), + content=StatusResponseModel( + status="Error", message=f"Terminal not found by QR", ru='QR-код не найден' + ).dict(), status_code=400, ) @@ -62,7 +78,9 @@ async def terminal_not_found_by_qr(req: starlette.requests.Request, exc: Termina @app.exception_handler(TerminalTokenNotFound) async def terminal_not_found_by_token(req: starlette.requests.Request, exc: TerminalTokenNotFound): return JSONResponse( - content=StatusResponseModel(status="Error", message=f"Terminal not found by token").dict(), + content=StatusResponseModel( + status="Error", message=f"Terminal not found by token", ru='Токен не найден' + ).dict(), status_code=400, ) @@ -70,37 +88,49 @@ async def terminal_not_found_by_token(req: starlette.requests.Request, exc: Term @app.exception_handler(UserNotFound) async def user_not_found(req: starlette.requests.Request, exc: UserNotFound): return JSONResponse( - content=StatusResponseModel(status="Error", message=f"User not found").dict(), status_code=404 + content=StatusResponseModel( + status="Error", message=f"User not found", ru='Пользователь не найден' + ).dict(), + status_code=404, ) @app.exception_handler(UnionStudentDuplicate) async def student_duplicate(req: starlette.requests.Request, exc: UnionStudentDuplicate): return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}").dict(), status_code=400 + content=StatusResponseModel( + status="Error", + message=f"{exc}", + ru='Один или более пользователей в списке не являются уникальными', + ).dict(), + status_code=400, ) @app.exception_handler(NotInUnion) async def not_in_union(req: starlette.requests.Request, exc: NotInUnion): - payload = StatusResponseModel(status="Error", message=f"{exc}").dict() - payload['ru'] = 'Отсутствует членство в профсоюзе' - return JSONResponse(content=payload, status_code=403) + return JSONResponse( + content=StatusResponseModel( + status="Error", message=f"{exc}", ru='Отсутствует членство в профсоюзе' + ).dict(), + status_code=403, + ) @app.exception_handler(PINGenerateError) async def generate_error(req: starlette.requests.Request, exc: PINGenerateError): return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}").dict(), status_code=500 + content=StatusResponseModel( + status="Error", message=f"{exc}", ru='Ошибка генерации ПИН-кода' + ).dict(), + status_code=500, ) @app.exception_handler(FileIsNotReceived) async def file_not_received(req: starlette.requests.Request, exc: FileIsNotReceived): - payload = StatusResponseModel(status="Error", message=f"{exc}").dict() - payload['ru'] = 'Файл не получен' return JSONResponse( - content=payload, + content=StatusResponseModel(status="Error", message=f"{exc}", ru='Файл не получен').dict(), status_code=400, ) @@ -108,45 +138,57 @@ async def file_not_received(req: starlette.requests.Request, exc: FileIsNotRecei @app.exception_handler(PINNotFound) async def pin_not_found(req: starlette.requests.Request, exc: PINNotFound): return JSONResponse( - content=StatusResponseModel(status="Error", message=f"Pin {exc.pin} not found").dict(), + content=StatusResponseModel( + status="Error", message=f"Pin {exc.pin} not found", ru='ПИН не найден' + ).dict(), status_code=404, ) @app.exception_handler(InvalidType) async def invalid_type(req: starlette.requests.Request, exc: InvalidType): - payload = StatusResponseModel(status="Error", message=f"{exc}").dict() - payload['ru'] = f'Неподдерживаемый формат файла. Допустимые: {settings.CONTENT_TYPES}' - return JSONResponse(content=payload, status_code=415) + return JSONResponse( + content=StatusResponseModel( + status="Error", + message=f"{exc}", + ru=f'Неподдерживаемый формат файла. Допустимые: {settings.CONTENT_TYPES}', + ).dict(), + status_code=415, + ) @app.exception_handler(AlreadyUploaded) async def already_upload(req: starlette.requests.Request, exc: AlreadyUploaded): return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}").dict(), status_code=415 + content=StatusResponseModel(status="Error", message=f"{exc}", ru='Файл уже загружен').dict(), + status_code=415, ) @app.exception_handler(IsCorrupted) async def is_corrupted(req: starlette.requests.Request, exc: IsCorrupted): - payload = StatusResponseModel(status="Error", message=f"{exc}").dict() - payload['ru'] = 'Файл повреждён' - return JSONResponse(content=payload, status_code=415) + return JSONResponse( + content=StatusResponseModel(status="Error", message=f"{exc}", ru='Файл повреждён').dict(), + status_code=415, + ) @app.exception_handler(UnprocessableFileInstance) async def unprocessable_file_instance(req: starlette.requests.Request, exc: UnprocessableFileInstance): return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}").dict(), status_code=422 + content=StatusResponseModel( + status="Error", message=f"{exc}", ru='Необрабатываемый экземпляр файла' + ).dict(), + status_code=422, ) @app.exception_handler(FileNotFound) async def file_not_found(req: starlette.requests.Request, exc: FileNotFound): - payload = StatusResponseModel(status="Error", message=f"{exc.count} file(s) not found").dict() - payload['ru'] = 'Файл не найден' return JSONResponse( - content=payload, + content=StatusResponseModel( + status="Error", message=f"{exc.count} file(s) not found", ru='Файл не найден' + ).dict(), status_code=404, ) @@ -154,5 +196,6 @@ async def file_not_found(req: starlette.requests.Request, exc: FileNotFound): @app.exception_handler(IsNotUploaded) async def not_uploaded(req: starlette.requests.Request, exc: IsNotUploaded): return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}").dict(), status_code=415 + content=StatusResponseModel(status="Error", message=f"{exc}", ru='Файл не загружен').dict(), + status_code=415, ) From a535a872e9fe329d917157151f22480fecaf421b Mon Sep 17 00:00:00 2001 From: Artem Morozov Date: Tue, 23 May 2023 00:16:39 +0300 Subject: [PATCH 3/4] Print-errors update. --- print_service/routes/file.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/print_service/routes/file.py b/print_service/routes/file.py index b8208c5..4340205 100644 --- a/print_service/routes/file.py +++ b/print_service/routes/file.py @@ -11,6 +11,7 @@ from pydantic import Field, validator from sqlalchemy import func, or_ +from print_service.base import StatusResponseModel from print_service.exceptions import ( AlreadyUploaded, FileIsNotReceived, @@ -100,7 +101,7 @@ class ReceiveOutput(BaseModel): @router.post( '', responses={ - 403: {'detail': 'User error'}, + 403: {'model': StatusResponseModel, 'detail': 'User error'}, }, response_model=SendOutput, ) @@ -147,8 +148,8 @@ async def send(inp: SendInput, settings: Settings = Depends(get_settings)): @router.post( '/{pin:str}', responses={ - 404: {'detail': 'Pin not found'}, - 415: {'detail': 'File error'}, + 404: {'model': StatusResponseModel, 'detail': 'Pin not found'}, + 415: {'model': StatusResponseModel, 'detail': 'File error'}, }, response_model=SendOutput, ) @@ -216,7 +217,7 @@ async def upload_file( @router.patch( '/{pin:str}', responses={ - 404: {'detail': 'Pin not found'}, + 404: {'model': StatusResponseModel, 'detail': 'Pin not found'}, }, response_model=SendOutput, ) @@ -261,8 +262,8 @@ async def update_file_options( @router.get( '/{pin:str}', responses={ - 404: {'detail': 'Pin not found'}, - 415: {'detail': 'File error'}, + 404: {'model': StatusResponseModel, 'detail': 'Pin not found'}, + 415: {'model': StatusResponseModel, 'detail': 'File error'}, }, response_model=ReceiveOutput, ) From 6ddbbdad85e03698873cac72d1733ab5abd8ee07 Mon Sep 17 00:00:00 2001 From: Artem Morozov Date: Tue, 23 May 2023 00:33:00 +0300 Subject: [PATCH 4/4] Print-errors update. --- print_service/routes/exc_handlers.py | 38 +++++++++++++++------------- print_service/routes/file.py | 9 ++++++- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/print_service/routes/exc_handlers.py b/print_service/routes/exc_handlers.py index 4b93b73..f10a38e 100644 --- a/print_service/routes/exc_handlers.py +++ b/print_service/routes/exc_handlers.py @@ -35,7 +35,7 @@ async def too_large_size(req: starlette.requests.Request, exc: TooLargeSize): content=StatusResponseModel( status="Error", message=f"{exc}", - ru=f'Размер файла превышает максимально допустимый: {settings.MAX_SIZE}', + ru=f"Размер файла превышает максимально допустимый: {settings.MAX_SIZE}", ).dict(), status_code=413, ) @@ -47,7 +47,7 @@ async def too_many_pages(req: starlette.requests.Request, exc: TooManyPages): content=StatusResponseModel( status="Error", message=f"{exc}", - ru=f'Количество запрошенных страниц превышает допустимое число: {settings.MAX_PAGE_COUNT}', + ru=f"Количество запрошенных страниц превышает допустимое число: {settings.MAX_PAGE_COUNT}", ).dict(), status_code=413, ) @@ -59,7 +59,7 @@ async def invalid_format(req: starlette.requests.Request, exc: TooManyPages): content=StatusResponseModel( status="Error", message=f"{exc}", - ru='Количество запрошенных страниц превышает их количество в файле', + ru="Количество запрошенных страниц превышает их количество в файле", ).dict(), status_code=416, ) @@ -69,7 +69,7 @@ async def invalid_format(req: starlette.requests.Request, exc: TooManyPages): async def terminal_not_found_by_qr(req: starlette.requests.Request, exc: TerminalQRNotFound): return JSONResponse( content=StatusResponseModel( - status="Error", message=f"Terminal not found by QR", ru='QR-код не найден' + status="Error", message="Terminal not found by QR", ru="QR-код не найден" ).dict(), status_code=400, ) @@ -79,7 +79,7 @@ async def terminal_not_found_by_qr(req: starlette.requests.Request, exc: Termina async def terminal_not_found_by_token(req: starlette.requests.Request, exc: TerminalTokenNotFound): return JSONResponse( content=StatusResponseModel( - status="Error", message=f"Terminal not found by token", ru='Токен не найден' + status="Error", message="Terminal not found by token", ru="Токен не найден" ).dict(), status_code=400, ) @@ -89,7 +89,7 @@ async def terminal_not_found_by_token(req: starlette.requests.Request, exc: Term async def user_not_found(req: starlette.requests.Request, exc: UserNotFound): return JSONResponse( content=StatusResponseModel( - status="Error", message=f"User not found", ru='Пользователь не найден' + status="Error", message="User not found", ru="Пользователь не найден" ).dict(), status_code=404, ) @@ -101,7 +101,7 @@ async def student_duplicate(req: starlette.requests.Request, exc: UnionStudentDu content=StatusResponseModel( status="Error", message=f"{exc}", - ru='Один или более пользователей в списке не являются уникальными', + ru="Один или более пользователей в списке не являются уникальными", ).dict(), status_code=400, ) @@ -111,7 +111,9 @@ async def student_duplicate(req: starlette.requests.Request, exc: UnionStudentDu async def not_in_union(req: starlette.requests.Request, exc: NotInUnion): return JSONResponse( content=StatusResponseModel( - status="Error", message=f"{exc}", ru='Отсутствует членство в профсоюзе' + status="Error", + message=f"{exc}", + ru="Отсутствует членство в профсоюзе", ).dict(), status_code=403, ) @@ -121,7 +123,9 @@ async def not_in_union(req: starlette.requests.Request, exc: NotInUnion): async def generate_error(req: starlette.requests.Request, exc: PINGenerateError): return JSONResponse( content=StatusResponseModel( - status="Error", message=f"{exc}", ru='Ошибка генерации ПИН-кода' + status="Error", + message=f"{exc}", + ru="Ошибка генерации ПИН-кода", ).dict(), status_code=500, ) @@ -130,7 +134,7 @@ async def generate_error(req: starlette.requests.Request, exc: PINGenerateError) @app.exception_handler(FileIsNotReceived) async def file_not_received(req: starlette.requests.Request, exc: FileIsNotReceived): return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}", ru='Файл не получен').dict(), + content=StatusResponseModel(status="Error", message=f"{exc}", ru="Файл не получен").dict(), status_code=400, ) @@ -139,7 +143,7 @@ async def file_not_received(req: starlette.requests.Request, exc: FileIsNotRecei async def pin_not_found(req: starlette.requests.Request, exc: PINNotFound): return JSONResponse( content=StatusResponseModel( - status="Error", message=f"Pin {exc.pin} not found", ru='ПИН не найден' + status="Error", message=f"Pin {exc.pin} not found", ru="ПИН не найден" ).dict(), status_code=404, ) @@ -151,7 +155,7 @@ async def invalid_type(req: starlette.requests.Request, exc: InvalidType): content=StatusResponseModel( status="Error", message=f"{exc}", - ru=f'Неподдерживаемый формат файла. Допустимые: {settings.CONTENT_TYPES}', + ru=f"Неподдерживаемый формат файла. Допустимые: {', '.join(settings.CONTENT_TYPES)}", ).dict(), status_code=415, ) @@ -160,7 +164,7 @@ async def invalid_type(req: starlette.requests.Request, exc: InvalidType): @app.exception_handler(AlreadyUploaded) async def already_upload(req: starlette.requests.Request, exc: AlreadyUploaded): return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}", ru='Файл уже загружен').dict(), + content=StatusResponseModel(status="Error", message=f"{exc}", ru="Файл уже загружен").dict(), status_code=415, ) @@ -168,7 +172,7 @@ async def already_upload(req: starlette.requests.Request, exc: AlreadyUploaded): @app.exception_handler(IsCorrupted) async def is_corrupted(req: starlette.requests.Request, exc: IsCorrupted): return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}", ru='Файл повреждён').dict(), + content=StatusResponseModel(status="Error", message=f"{exc}", ru="Файл повреждён").dict(), status_code=415, ) @@ -177,7 +181,7 @@ async def is_corrupted(req: starlette.requests.Request, exc: IsCorrupted): async def unprocessable_file_instance(req: starlette.requests.Request, exc: UnprocessableFileInstance): return JSONResponse( content=StatusResponseModel( - status="Error", message=f"{exc}", ru='Необрабатываемый экземпляр файла' + status="Error", message=f"{exc}", ru="Необрабатываемый экземпляр файла" ).dict(), status_code=422, ) @@ -187,7 +191,7 @@ async def unprocessable_file_instance(req: starlette.requests.Request, exc: Unpr async def file_not_found(req: starlette.requests.Request, exc: FileNotFound): return JSONResponse( content=StatusResponseModel( - status="Error", message=f"{exc.count} file(s) not found", ru='Файл не найден' + status="Error", message=f"{exc.count} file(s) not found", ru="Файл не найден" ).dict(), status_code=404, ) @@ -196,6 +200,6 @@ async def file_not_found(req: starlette.requests.Request, exc: FileNotFound): @app.exception_handler(IsNotUploaded) async def not_uploaded(req: starlette.requests.Request, exc: IsNotUploaded): return JSONResponse( - content=StatusResponseModel(status="Error", message=f"{exc}", ru='Файл не загружен').dict(), + content=StatusResponseModel(status="Error", message=f"{exc}", ru="Файл не загружен").dict(), status_code=415, ) diff --git a/print_service/routes/file.py b/print_service/routes/file.py index 4340205..36248f0 100644 --- a/print_service/routes/file.py +++ b/print_service/routes/file.py @@ -102,6 +102,7 @@ class ReceiveOutput(BaseModel): '', responses={ 403: {'model': StatusResponseModel, 'detail': 'User error'}, + 500: {'model': StatusResponseModel, 'detail': 'PIN generate error'}, }, response_model=SendOutput, ) @@ -125,7 +126,7 @@ async def send(inp: SendInput, settings: Settings = Depends(get_settings)): try: pin = generate_pin(db.session) except RuntimeError: - raise PINGenerateError + raise PINGenerateError() filename = generate_filename(inp.filename) file_model = FileModel(pin=pin, file=filename) file_model.owner = user @@ -148,8 +149,11 @@ async def send(inp: SendInput, settings: Settings = Depends(get_settings)): @router.post( '/{pin:str}', responses={ + 400: {'model': StatusResponseModel, 'detail': 'File is not received'}, 404: {'model': StatusResponseModel, 'detail': 'Pin not found'}, 415: {'model': StatusResponseModel, 'detail': 'File error'}, + 413: {'model': StatusResponseModel, 'detail': 'Too large file'}, + 416: {'model': StatusResponseModel, 'detail': 'Invalid page request'}, }, response_model=SendOutput, ) @@ -218,6 +222,8 @@ async def upload_file( '/{pin:str}', responses={ 404: {'model': StatusResponseModel, 'detail': 'Pin not found'}, + 413: {'model': StatusResponseModel, 'detail': 'Too many pages'}, + 416: {'model': StatusResponseModel, 'detail': 'Invalid page request'}, }, response_model=SendOutput, ) @@ -264,6 +270,7 @@ async def update_file_options( responses={ 404: {'model': StatusResponseModel, 'detail': 'Pin not found'}, 415: {'model': StatusResponseModel, 'detail': 'File error'}, + 416: {'model': StatusResponseModel, 'detail': 'Invalid page request'}, }, response_model=ReceiveOutput, )