diff --git a/README.md b/README.md index caa961b..685832f 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Generic document management service with S3 storage and PDF field discovery. ### Upload Document ``` -POST /api/documents/upload +POST /api/v1/documents/upload Content-Type: multipart/form-data Authorization: Bearer @@ -34,7 +34,7 @@ Response: ### Rewrite Document ``` -PUT /api/documents/{document_id} +PUT /api/v1/documents/{document_id} Content-Type: multipart/form-data Authorization: Bearer @@ -52,7 +52,7 @@ Response: ### Get Document Metadata ``` -GET /api/documents/{document_id} +GET /api/v1/documents/{document_id} Authorization: Bearer Response: @@ -72,7 +72,7 @@ Response: ### Get Download URL ``` -GET /api/documents/{document_id}/download-url?expires_in=3600 +GET /api/v1/documents/{document_id}/download-url?expires_in=3600 Authorization: Bearer Response: @@ -85,7 +85,7 @@ Response: ### Get PDF Fields ``` -GET /api/documents/{document_id}/fields +GET /api/v1/documents/{document_id}/fields Authorization: Bearer Response: @@ -106,7 +106,7 @@ Response: ### Delete Document ``` -DELETE /api/documents/{document_id} +DELETE /api/v1/documents/{document_id} Authorization: Bearer Response: diff --git a/app/routers/documents.py b/app/routers/documents.py index eeb6b67..8cccdc4 100644 --- a/app/routers/documents.py +++ b/app/routers/documents.py @@ -7,7 +7,7 @@ from app.enums import DocumentType from app.models import DocumentMetadata, UploadResponse, DownloadUrlResponse, FieldsResponse from app.logger import get_logger -router = APIRouter(prefix="/api/documents", tags=["documents"]) +router = APIRouter(prefix="/api/v1/documents", tags=["documents"]) logger = get_logger(__name__) @router.post("/upload", response_model=UploadResponse) diff --git a/tests/test_documents.py b/tests/test_documents.py index 95fd63b..9f386b9 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -39,7 +39,7 @@ class TestDocumentUpload: headers = {"Authorization": sample_auth_token} response = test_client.post( - "/api/documents/upload", + "/api/v1/documents/upload", files=files, data=data, headers=headers @@ -61,7 +61,7 @@ class TestDocumentUpload: headers = {"Authorization": sample_auth_token} response = test_client.post( - "/api/documents/upload", + "/api/v1/documents/upload", files=files, data=data, headers=headers @@ -80,7 +80,7 @@ class TestDocumentUpload: headers = {"Authorization": sample_auth_token} response = test_client.post( - "/api/documents/upload", + "/api/v1/documents/upload", files=files, data=data, headers=headers @@ -97,7 +97,7 @@ class TestDocumentUpload: data = {"org_id": "test-org-123"} response = test_client.post( - "/api/documents/upload", + "/api/v1/documents/upload", files=files, data=data ) @@ -113,7 +113,7 @@ class TestDocumentUpload: headers = {"Authorization": "Invalid token"} response = test_client.post( - "/api/documents/upload", + "/api/v1/documents/upload", files=files, data=data, headers=headers @@ -127,7 +127,7 @@ class TestDocumentUpload: headers = {"Authorization": sample_auth_token} response = test_client.post( - "/api/documents/upload", + "/api/v1/documents/upload", data=data, headers=headers ) @@ -145,7 +145,7 @@ class TestDocumentMetadata: headers = {"Authorization": sample_auth_token} response = test_client.get( - "/api/documents/test-doc-456", + "/api/v1/documents/test-doc-456", params={"org_id": "test-org-123"}, headers=headers ) @@ -155,7 +155,7 @@ class TestDocumentMetadata: def test_get_document_without_auth_returns_401(self, test_client): """Test getting document without auth returns 401.""" - response = test_client.get("/api/documents/test-doc-456") + response = test_client.get("/api/v1/documents/test-doc-456") assert response.status_code == 401 @@ -168,7 +168,7 @@ class TestDownloadUrl: headers = {"Authorization": sample_auth_token} response = test_client.get( - "/api/documents/test-doc-456/download-url", + "/api/v1/documents/test-doc-456/download-url", params={"org_id": "test-org-123"}, headers=headers ) @@ -178,7 +178,7 @@ class TestDownloadUrl: def test_get_download_url_without_auth_returns_401(self, test_client): """Test getting download URL without auth returns 401.""" - response = test_client.get("/api/documents/test-doc-456/download-url") + response = test_client.get("/api/v1/documents/test-doc-456/download-url") assert response.status_code == 401 @@ -195,7 +195,7 @@ class TestPDFFieldDiscovery: headers = {"Authorization": sample_auth_token} upload_response = test_client.post( - "/api/documents/upload", + "/api/v1/documents/upload", files=files, data=data, headers=headers @@ -207,7 +207,7 @@ class TestPDFFieldDiscovery: # Get fields headers = {"Authorization": sample_auth_token} response = test_client.get( - f"/api/documents/{document_id}/fields", + f"/api/v1/documents/{document_id}/fields", params={"org_id": "test-org-123"}, headers=headers ) @@ -235,7 +235,7 @@ class TestPDFFieldDiscovery: headers = {"Authorization": sample_auth_token} upload_response = test_client.post( - "/api/documents/upload", + "/api/v1/documents/upload", files=files, data=data, headers=headers @@ -247,7 +247,7 @@ class TestPDFFieldDiscovery: # Get fields headers = {"Authorization": sample_auth_token} response = test_client.get( - f"/api/documents/{document_id}/fields", + f"/api/v1/documents/{document_id}/fields", params={"org_id": "test-org-123"}, headers=headers ) @@ -266,7 +266,7 @@ class TestPDFFieldDiscovery: headers = {"Authorization": sample_auth_token} upload_response = test_client.post( - "/api/documents/upload", + "/api/v1/documents/upload", files=files, data=data, headers=headers @@ -278,7 +278,7 @@ class TestPDFFieldDiscovery: # Get fields headers = {"Authorization": sample_auth_token} response = test_client.get( - f"/api/documents/{document_id}/fields", + f"/api/v1/documents/{document_id}/fields", params={"org_id": "test-org-123"}, headers=headers ) @@ -290,7 +290,7 @@ class TestPDFFieldDiscovery: def test_get_pdf_fields_without_auth_returns_401(self, test_client): """Test getting PDF fields without auth returns 401.""" - response = test_client.get("/api/documents/test-doc-456/fields") + response = test_client.get("/api/v1/documents/test-doc-456/fields") assert response.status_code == 401 @@ -303,7 +303,7 @@ class TestDocumentDeletion: headers = {"Authorization": sample_auth_token} response = test_client.delete( - "/api/documents/test-doc-456", + "/api/v1/documents/test-doc-456", params={"org_id": "test-org-123"}, headers=headers ) @@ -313,7 +313,7 @@ class TestDocumentDeletion: def test_delete_document_without_auth_returns_401(self, test_client): """Test deleting document without auth returns 401.""" - response = test_client.delete("/api/documents/test-doc-456") + response = test_client.delete("/api/v1/documents/test-doc-456") assert response.status_code == 401 @@ -418,7 +418,7 @@ class TestCompleteWorkflow: headers = {"Authorization": sample_auth_token} upload_response = test_client.post( - "/api/documents/upload", + "/api/v1/documents/upload", files=files, data=data, headers=headers @@ -430,28 +430,28 @@ class TestCompleteWorkflow: # Get metadata headers = {"Authorization": sample_auth_token} metadata_response = test_client.get( - f"/api/documents/{document_id}", + f"/api/v1/documents/{document_id}", params={"org_id": "test-org-123"}, headers=headers ) # Get fields fields_response = test_client.get( - f"/api/documents/{document_id}/fields", + f"/api/v1/documents/{document_id}/fields", params={"org_id": "test-org-123"}, headers=headers ) # Get download URL download_response = test_client.get( - f"/api/documents/{document_id}/download-url", + f"/api/v1/documents/{document_id}/download-url", params={"org_id": "test-org-123"}, headers=headers ) # Delete document delete_response = test_client.delete( - f"/api/documents/{document_id}", + f"/api/v1/documents/{document_id}", params={"org_id": "test-org-123"}, headers=headers )