88from api .core .filesystem import FileSystem
99from api .dependencies import filesystem_dep
1010from api .schemas import file as file_schemas
11+ from api .schemas .common import ErrorResponse
1112
1213router = APIRouter ()
1314
1617 "/files/{file_path:path}/download" ,
1718 response_model = None ,
1819 response_class = Response ,
19- description = "Download a file" ,
20+ status_code = status .HTTP_200_OK ,
21+ description = "Download a file from the file system" ,
22+ responses = {
23+ 200 : {"description" : "File successfully downloaded" },
24+ 404 : {"description" : "File not found" , "model" : ErrorResponse }
25+ }
2026)
2127def download_file (
2228 file_path : str , filesystem : FileSystem = Depends (filesystem_dep )
@@ -30,7 +36,12 @@ def download_file(
3036@router .get (
3137 "/files/{file_path:path}/url" ,
3238 response_model = file_schemas .FileHTTPRequest ,
39+ status_code = status .HTTP_200_OK ,
3340 description = "Get request parameters (pre-signed URL) to download a file" ,
41+ responses = {
42+ 200 : {"description" : "Successfully generated download URL" , "model" : file_schemas .FileHTTPRequest },
43+ 404 : {"description" : "File not found" , "model" : ErrorResponse }
44+ }
3445)
3546def get_download_presigned_url (
3647 file_path : str , request : Request , filesystem : FileSystem = Depends (filesystem_dep )
@@ -46,7 +57,12 @@ def get_download_presigned_url(
4657@router .get (
4758 "/files/{base_path:path}" ,
4859 response_model = list [file_schemas .FileInfo ],
49- description = "List files in a directory" ,
60+ status_code = status .HTTP_200_OK ,
61+ description = "List files and directories in a specified path" ,
62+ responses = {
63+ 200 : {"description" : "Successfully retrieved file listing" , "model" : list [file_schemas .FileInfo ]},
64+ 404 : {"description" : "Directory not found" , "model" : ErrorResponse }
65+ }
5066)
5167def list_files (
5268 base_path : str = "" ,
@@ -67,7 +83,11 @@ def list_files(
6783 "/files/{f_type}/{base_path:path}/upload" ,
6884 response_model = file_schemas .FileInfo ,
6985 status_code = status .HTTP_201_CREATED ,
70- description = "Upload a file" ,
86+ description = "Upload a file to the specified path" ,
87+ responses = {
88+ 201 : {"description" : "File successfully uploaded" , "model" : file_schemas .FileInfo },
89+ 400 : {"description" : "Invalid upload parameters" , "model" : ErrorResponse }
90+ }
7191)
7292def upload_file (
7393 f_type : models .UploadFileTypes ,
@@ -86,6 +106,10 @@ def upload_file(
86106 status_code = status .HTTP_201_CREATED ,
87107 response_model = file_schemas .FileHTTPRequest ,
88108 description = "Get request parameters (pre-signed URL) to upload a file" ,
109+ responses = {
110+ 201 : {"description" : "Successfully generated upload URL" , "model" : file_schemas .FileHTTPRequest },
111+ 400 : {"description" : "Invalid parameters" , "model" : ErrorResponse }
112+ }
89113)
90114def get_upload_presigned_url (
91115 f_type : models .UploadFileTypes ,
@@ -102,7 +126,12 @@ def get_upload_presigned_url(
102126@router .post (
103127 "/files/{f_type}/{base_path:path}/" ,
104128 status_code = status .HTTP_201_CREATED ,
105- description = "Create a directory" ,
129+ response_model = None ,
130+ description = "Create a new directory at the specified path" ,
131+ responses = {
132+ 201 : {"description" : "Directory successfully created" },
133+ 400 : {"description" : "Invalid directory parameters" , "model" : ErrorResponse }
134+ }
106135)
107136def create_directory (
108137 f_type : models .UploadFileTypes ,
@@ -115,7 +144,13 @@ def create_directory(
115144@router .put (
116145 "/files/{file_path:path}" ,
117146 response_model = file_schemas .FileInfo ,
118- description = "Rename a file" ,
147+ status_code = status .HTTP_200_OK ,
148+ description = "Rename or move a file to a new path" ,
149+ responses = {
150+ 200 : {"description" : "File successfully renamed/moved" , "model" : file_schemas .FileInfo },
151+ 404 : {"description" : "File not found" , "model" : ErrorResponse },
152+ 405 : {"description" : "Operation not allowed (e.g., trying to rename directory)" , "model" : ErrorResponse }
153+ }
119154)
120155def rename_file (
121156 file_path : str ,
@@ -138,7 +173,11 @@ def rename_file(
138173 "/files/{file_path:path}" ,
139174 status_code = status .HTTP_204_NO_CONTENT ,
140175 response_model = None ,
141- description = "Delete a file or directory" ,
176+ description = "Delete a file or directory and all its contents" ,
177+ responses = {
178+ 204 : {"description" : "File or directory successfully deleted" },
179+ 404 : {"description" : "File or directory not found" , "model" : ErrorResponse }
180+ }
142181)
143182def delete_file (
144183 file_path : str , filesystem : FileSystem = Depends (filesystem_dep )
0 commit comments