feat: implement API versioning /api/v1/
- All backend routers moved to /api/v1/ prefix
- Frontend BASE_URL updated to /api/v1
- Setup redirect middleware updated to redirect to /api/v1/setup
- Health router path fixed: prefix=/api/v1/health, @router.get('')
- conftest.py: set server_status=online for test fixture
- Created Docs/API_VERSIONING.md with deprecation policy
- Updated Docs/Backend-Development.md with versioning section
- Updated Instructions.md curl examples
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -27,7 +27,7 @@ def test_correlation_middleware_generates_uuid_when_header_absent() -> None:
|
||||
|
||||
# Test with TestClient (synchronous)
|
||||
client = TestClient(app)
|
||||
response = client.get("/api/health")
|
||||
response = client.get("/api/v1/health")
|
||||
|
||||
# Should have correlation ID header in response
|
||||
assert "X-Correlation-ID" in response.headers
|
||||
@@ -53,7 +53,7 @@ def test_correlation_middleware_preserves_header_from_request() -> None:
|
||||
|
||||
client = TestClient(app)
|
||||
test_correlation_id = "550e8400-e29b-41d4-a716-446655440000"
|
||||
response = client.get("/api/health", headers={"X-Correlation-ID": test_correlation_id})
|
||||
response = client.get("/api/v1/health", headers={"X-Correlation-ID": test_correlation_id})
|
||||
|
||||
# Should return the same correlation ID in response
|
||||
assert response.headers["X-Correlation-ID"] == test_correlation_id
|
||||
@@ -76,7 +76,7 @@ def test_correlation_middleware_stores_in_request_state() -> None:
|
||||
|
||||
# Make a request and verify correlation ID is available to handlers
|
||||
test_correlation_id = "550e8400-e29b-41d4-a716-446655440000"
|
||||
response = client.get("/api/health", headers={"X-Correlation-ID": test_correlation_id})
|
||||
response = client.get("/api/v1/health", headers={"X-Correlation-ID": test_correlation_id})
|
||||
|
||||
# The health endpoint should return 200, proving the correlation ID was processed
|
||||
assert response.status_code == 200
|
||||
@@ -100,11 +100,11 @@ def test_correlation_id_in_response_headers() -> None:
|
||||
client = TestClient(app)
|
||||
|
||||
# Test without providing header (should generate one)
|
||||
response = client.get("/api/health")
|
||||
response = client.get("/api/v1/health")
|
||||
assert "X-Correlation-ID" in response.headers
|
||||
|
||||
# Test with providing header (should preserve it)
|
||||
test_id = "test-correlation-id-12345"
|
||||
response = client.get("/api/health", headers={"X-Correlation-ID": test_id})
|
||||
response = client.get("/api/v1/health", headers={"X-Correlation-ID": test_id})
|
||||
assert response.headers["X-Correlation-ID"] == test_id
|
||||
|
||||
|
||||
Reference in New Issue
Block a user