This commit is contained in:
12
README.md
12
README.md
@@ -16,7 +16,7 @@ Generic document management service with S3 storage and PDF field discovery.
|
|||||||
|
|
||||||
### Upload Document
|
### Upload Document
|
||||||
```
|
```
|
||||||
POST /api/documents/upload
|
POST /api/v1/documents/upload
|
||||||
Content-Type: multipart/form-data
|
Content-Type: multipart/form-data
|
||||||
Authorization: Bearer <token>
|
Authorization: Bearer <token>
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ Response:
|
|||||||
|
|
||||||
### Rewrite Document
|
### Rewrite Document
|
||||||
```
|
```
|
||||||
PUT /api/documents/{document_id}
|
PUT /api/v1/documents/{document_id}
|
||||||
Content-Type: multipart/form-data
|
Content-Type: multipart/form-data
|
||||||
Authorization: Bearer <token>
|
Authorization: Bearer <token>
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ Response:
|
|||||||
|
|
||||||
### Get Document Metadata
|
### Get Document Metadata
|
||||||
```
|
```
|
||||||
GET /api/documents/{document_id}
|
GET /api/v1/documents/{document_id}
|
||||||
Authorization: Bearer <token>
|
Authorization: Bearer <token>
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
@@ -72,7 +72,7 @@ Response:
|
|||||||
|
|
||||||
### Get Download URL
|
### 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 <token>
|
Authorization: Bearer <token>
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
@@ -85,7 +85,7 @@ Response:
|
|||||||
|
|
||||||
### Get PDF Fields
|
### Get PDF Fields
|
||||||
```
|
```
|
||||||
GET /api/documents/{document_id}/fields
|
GET /api/v1/documents/{document_id}/fields
|
||||||
Authorization: Bearer <token>
|
Authorization: Bearer <token>
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
@@ -106,7 +106,7 @@ Response:
|
|||||||
|
|
||||||
### Delete Document
|
### Delete Document
|
||||||
```
|
```
|
||||||
DELETE /api/documents/{document_id}
|
DELETE /api/v1/documents/{document_id}
|
||||||
Authorization: Bearer <token>
|
Authorization: Bearer <token>
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from app.enums import DocumentType
|
|||||||
from app.models import DocumentMetadata, UploadResponse, DownloadUrlResponse, FieldsResponse
|
from app.models import DocumentMetadata, UploadResponse, DownloadUrlResponse, FieldsResponse
|
||||||
from app.logger import get_logger
|
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__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
@router.post("/upload", response_model=UploadResponse)
|
@router.post("/upload", response_model=UploadResponse)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class TestDocumentUpload:
|
|||||||
headers = {"Authorization": sample_auth_token}
|
headers = {"Authorization": sample_auth_token}
|
||||||
|
|
||||||
response = test_client.post(
|
response = test_client.post(
|
||||||
"/api/documents/upload",
|
"/api/v1/documents/upload",
|
||||||
files=files,
|
files=files,
|
||||||
data=data,
|
data=data,
|
||||||
headers=headers
|
headers=headers
|
||||||
@@ -61,7 +61,7 @@ class TestDocumentUpload:
|
|||||||
headers = {"Authorization": sample_auth_token}
|
headers = {"Authorization": sample_auth_token}
|
||||||
|
|
||||||
response = test_client.post(
|
response = test_client.post(
|
||||||
"/api/documents/upload",
|
"/api/v1/documents/upload",
|
||||||
files=files,
|
files=files,
|
||||||
data=data,
|
data=data,
|
||||||
headers=headers
|
headers=headers
|
||||||
@@ -80,7 +80,7 @@ class TestDocumentUpload:
|
|||||||
headers = {"Authorization": sample_auth_token}
|
headers = {"Authorization": sample_auth_token}
|
||||||
|
|
||||||
response = test_client.post(
|
response = test_client.post(
|
||||||
"/api/documents/upload",
|
"/api/v1/documents/upload",
|
||||||
files=files,
|
files=files,
|
||||||
data=data,
|
data=data,
|
||||||
headers=headers
|
headers=headers
|
||||||
@@ -97,7 +97,7 @@ class TestDocumentUpload:
|
|||||||
data = {"org_id": "test-org-123"}
|
data = {"org_id": "test-org-123"}
|
||||||
|
|
||||||
response = test_client.post(
|
response = test_client.post(
|
||||||
"/api/documents/upload",
|
"/api/v1/documents/upload",
|
||||||
files=files,
|
files=files,
|
||||||
data=data
|
data=data
|
||||||
)
|
)
|
||||||
@@ -113,7 +113,7 @@ class TestDocumentUpload:
|
|||||||
headers = {"Authorization": "Invalid token"}
|
headers = {"Authorization": "Invalid token"}
|
||||||
|
|
||||||
response = test_client.post(
|
response = test_client.post(
|
||||||
"/api/documents/upload",
|
"/api/v1/documents/upload",
|
||||||
files=files,
|
files=files,
|
||||||
data=data,
|
data=data,
|
||||||
headers=headers
|
headers=headers
|
||||||
@@ -127,7 +127,7 @@ class TestDocumentUpload:
|
|||||||
headers = {"Authorization": sample_auth_token}
|
headers = {"Authorization": sample_auth_token}
|
||||||
|
|
||||||
response = test_client.post(
|
response = test_client.post(
|
||||||
"/api/documents/upload",
|
"/api/v1/documents/upload",
|
||||||
data=data,
|
data=data,
|
||||||
headers=headers
|
headers=headers
|
||||||
)
|
)
|
||||||
@@ -145,7 +145,7 @@ class TestDocumentMetadata:
|
|||||||
headers = {"Authorization": sample_auth_token}
|
headers = {"Authorization": sample_auth_token}
|
||||||
|
|
||||||
response = test_client.get(
|
response = test_client.get(
|
||||||
"/api/documents/test-doc-456",
|
"/api/v1/documents/test-doc-456",
|
||||||
params={"org_id": "test-org-123"},
|
params={"org_id": "test-org-123"},
|
||||||
headers=headers
|
headers=headers
|
||||||
)
|
)
|
||||||
@@ -155,7 +155,7 @@ class TestDocumentMetadata:
|
|||||||
|
|
||||||
def test_get_document_without_auth_returns_401(self, test_client):
|
def test_get_document_without_auth_returns_401(self, test_client):
|
||||||
"""Test getting document without auth returns 401."""
|
"""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
|
assert response.status_code == 401
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ class TestDownloadUrl:
|
|||||||
headers = {"Authorization": sample_auth_token}
|
headers = {"Authorization": sample_auth_token}
|
||||||
|
|
||||||
response = test_client.get(
|
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"},
|
params={"org_id": "test-org-123"},
|
||||||
headers=headers
|
headers=headers
|
||||||
)
|
)
|
||||||
@@ -178,7 +178,7 @@ class TestDownloadUrl:
|
|||||||
|
|
||||||
def test_get_download_url_without_auth_returns_401(self, test_client):
|
def test_get_download_url_without_auth_returns_401(self, test_client):
|
||||||
"""Test getting download URL without auth returns 401."""
|
"""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
|
assert response.status_code == 401
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ class TestPDFFieldDiscovery:
|
|||||||
headers = {"Authorization": sample_auth_token}
|
headers = {"Authorization": sample_auth_token}
|
||||||
|
|
||||||
upload_response = test_client.post(
|
upload_response = test_client.post(
|
||||||
"/api/documents/upload",
|
"/api/v1/documents/upload",
|
||||||
files=files,
|
files=files,
|
||||||
data=data,
|
data=data,
|
||||||
headers=headers
|
headers=headers
|
||||||
@@ -207,7 +207,7 @@ class TestPDFFieldDiscovery:
|
|||||||
# Get fields
|
# Get fields
|
||||||
headers = {"Authorization": sample_auth_token}
|
headers = {"Authorization": sample_auth_token}
|
||||||
response = test_client.get(
|
response = test_client.get(
|
||||||
f"/api/documents/{document_id}/fields",
|
f"/api/v1/documents/{document_id}/fields",
|
||||||
params={"org_id": "test-org-123"},
|
params={"org_id": "test-org-123"},
|
||||||
headers=headers
|
headers=headers
|
||||||
)
|
)
|
||||||
@@ -235,7 +235,7 @@ class TestPDFFieldDiscovery:
|
|||||||
headers = {"Authorization": sample_auth_token}
|
headers = {"Authorization": sample_auth_token}
|
||||||
|
|
||||||
upload_response = test_client.post(
|
upload_response = test_client.post(
|
||||||
"/api/documents/upload",
|
"/api/v1/documents/upload",
|
||||||
files=files,
|
files=files,
|
||||||
data=data,
|
data=data,
|
||||||
headers=headers
|
headers=headers
|
||||||
@@ -247,7 +247,7 @@ class TestPDFFieldDiscovery:
|
|||||||
# Get fields
|
# Get fields
|
||||||
headers = {"Authorization": sample_auth_token}
|
headers = {"Authorization": sample_auth_token}
|
||||||
response = test_client.get(
|
response = test_client.get(
|
||||||
f"/api/documents/{document_id}/fields",
|
f"/api/v1/documents/{document_id}/fields",
|
||||||
params={"org_id": "test-org-123"},
|
params={"org_id": "test-org-123"},
|
||||||
headers=headers
|
headers=headers
|
||||||
)
|
)
|
||||||
@@ -266,7 +266,7 @@ class TestPDFFieldDiscovery:
|
|||||||
headers = {"Authorization": sample_auth_token}
|
headers = {"Authorization": sample_auth_token}
|
||||||
|
|
||||||
upload_response = test_client.post(
|
upload_response = test_client.post(
|
||||||
"/api/documents/upload",
|
"/api/v1/documents/upload",
|
||||||
files=files,
|
files=files,
|
||||||
data=data,
|
data=data,
|
||||||
headers=headers
|
headers=headers
|
||||||
@@ -278,7 +278,7 @@ class TestPDFFieldDiscovery:
|
|||||||
# Get fields
|
# Get fields
|
||||||
headers = {"Authorization": sample_auth_token}
|
headers = {"Authorization": sample_auth_token}
|
||||||
response = test_client.get(
|
response = test_client.get(
|
||||||
f"/api/documents/{document_id}/fields",
|
f"/api/v1/documents/{document_id}/fields",
|
||||||
params={"org_id": "test-org-123"},
|
params={"org_id": "test-org-123"},
|
||||||
headers=headers
|
headers=headers
|
||||||
)
|
)
|
||||||
@@ -290,7 +290,7 @@ class TestPDFFieldDiscovery:
|
|||||||
|
|
||||||
def test_get_pdf_fields_without_auth_returns_401(self, test_client):
|
def test_get_pdf_fields_without_auth_returns_401(self, test_client):
|
||||||
"""Test getting PDF fields without auth returns 401."""
|
"""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
|
assert response.status_code == 401
|
||||||
|
|
||||||
@@ -303,7 +303,7 @@ class TestDocumentDeletion:
|
|||||||
headers = {"Authorization": sample_auth_token}
|
headers = {"Authorization": sample_auth_token}
|
||||||
|
|
||||||
response = test_client.delete(
|
response = test_client.delete(
|
||||||
"/api/documents/test-doc-456",
|
"/api/v1/documents/test-doc-456",
|
||||||
params={"org_id": "test-org-123"},
|
params={"org_id": "test-org-123"},
|
||||||
headers=headers
|
headers=headers
|
||||||
)
|
)
|
||||||
@@ -313,7 +313,7 @@ class TestDocumentDeletion:
|
|||||||
|
|
||||||
def test_delete_document_without_auth_returns_401(self, test_client):
|
def test_delete_document_without_auth_returns_401(self, test_client):
|
||||||
"""Test deleting document without auth returns 401."""
|
"""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
|
assert response.status_code == 401
|
||||||
|
|
||||||
@@ -418,7 +418,7 @@ class TestCompleteWorkflow:
|
|||||||
headers = {"Authorization": sample_auth_token}
|
headers = {"Authorization": sample_auth_token}
|
||||||
|
|
||||||
upload_response = test_client.post(
|
upload_response = test_client.post(
|
||||||
"/api/documents/upload",
|
"/api/v1/documents/upload",
|
||||||
files=files,
|
files=files,
|
||||||
data=data,
|
data=data,
|
||||||
headers=headers
|
headers=headers
|
||||||
@@ -430,28 +430,28 @@ class TestCompleteWorkflow:
|
|||||||
# Get metadata
|
# Get metadata
|
||||||
headers = {"Authorization": sample_auth_token}
|
headers = {"Authorization": sample_auth_token}
|
||||||
metadata_response = test_client.get(
|
metadata_response = test_client.get(
|
||||||
f"/api/documents/{document_id}",
|
f"/api/v1/documents/{document_id}",
|
||||||
params={"org_id": "test-org-123"},
|
params={"org_id": "test-org-123"},
|
||||||
headers=headers
|
headers=headers
|
||||||
)
|
)
|
||||||
|
|
||||||
# Get fields
|
# Get fields
|
||||||
fields_response = test_client.get(
|
fields_response = test_client.get(
|
||||||
f"/api/documents/{document_id}/fields",
|
f"/api/v1/documents/{document_id}/fields",
|
||||||
params={"org_id": "test-org-123"},
|
params={"org_id": "test-org-123"},
|
||||||
headers=headers
|
headers=headers
|
||||||
)
|
)
|
||||||
|
|
||||||
# Get download URL
|
# Get download URL
|
||||||
download_response = test_client.get(
|
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"},
|
params={"org_id": "test-org-123"},
|
||||||
headers=headers
|
headers=headers
|
||||||
)
|
)
|
||||||
|
|
||||||
# Delete document
|
# Delete document
|
||||||
delete_response = test_client.delete(
|
delete_response = test_client.delete(
|
||||||
f"/api/documents/{document_id}",
|
f"/api/v1/documents/{document_id}",
|
||||||
params={"org_id": "test-org-123"},
|
params={"org_id": "test-org-123"},
|
||||||
headers=headers
|
headers=headers
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user