From a6706435f189894bb182c2414b7bc0c11bfab47b Mon Sep 17 00:00:00 2001 From: Paul Sanders Date: Wed, 13 May 2026 15:44:27 -0400 Subject: [PATCH 1/3] Switch from httpx to httpx2 httpx no longer seems to be supported. At a minimum the maintainers have closed the ability for anyone to report issues. The Pydantic team has forked the project to httpx2 to continue development --- src/fastapi/fastapi_installer.rs | 2 +- src/fastapi/test_files.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fastapi/fastapi_installer.rs b/src/fastapi/fastapi_installer.rs index 8b50a444..f90ac60b 100644 --- a/src/fastapi/fastapi_installer.rs +++ b/src/fastapi/fastapi_installer.rs @@ -19,7 +19,7 @@ const FASTAPI_BASE_DEPENDENCIES: &[&str] = &[ "valkey", ]; -const FASTAPI_BASE_DEV_DEPENDENCIES: &[&str] = &["httpx", "pytest-xdist"]; +const FASTAPI_BASE_DEV_DEPENDENCIES: &[&str] = &["httpx2", "pytest-xdist"]; pub fn install_fastapi_dependencies(project_info: &ProjectInfo) -> Result<()> { match project_info.project_manager { diff --git a/src/fastapi/test_files.rs b/src/fastapi/test_files.rs index 849cf72b..06f60a76 100644 --- a/src/fastapi/test_files.rs +++ b/src/fastapi/test_files.rs @@ -182,7 +182,7 @@ from uuid import uuid4 import asyncpg import pytest -from httpx import ASGITransport, AsyncClient +from httpx2 import ASGITransport, AsyncClient from {module}.api.deps import get_cache_client, get_db_pool from {module}.core.cache import cache @@ -395,7 +395,7 @@ fn create_health_route_test_file(project_info: &ProjectInfo) -> String { r#"from unittest.mock import AsyncMock, MagicMock import pytest -from httpx import ASGITransport, AsyncClient +from httpx2 import ASGITransport, AsyncClient from {module}.api.deps import get_cache_client, get_db_pool from {module}.core.config import settings From e45e7465b1acb1e1f9c468f3d0103d245ff71f5b Mon Sep 17 00:00:00 2001 From: Paul Sanders Date: Thu, 14 May 2026 20:22:00 -0400 Subject: [PATCH 2/3] Fix tests --- src/fastapi/test_files.rs | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/src/fastapi/test_files.rs b/src/fastapi/test_files.rs index 06f60a76..d97b7260 100644 --- a/src/fastapi/test_files.rs +++ b/src/fastapi/test_files.rs @@ -1386,7 +1386,6 @@ fn create_main_test_file(project_info: &ProjectInfo) -> String { r#"import importlib from unittest.mock import patch -from fastapi.testclient import TestClient from loguru import logger from {module} import main @@ -1404,29 +1403,6 @@ async def test_http_exception_handler(test_client, normal_user_token_headers, ca assert response.status_code == 500 assert "Server crashed" in caplog.text - - -def test_cors_middleware_added(test_client): - with patch.object( - type(settings), - "all_cors_origins", - new=property(lambda _: ["https://example.com"]), - ): - importlib.reload(main) - app = main.app - client = TestClient(app) - - resp = client.options( - "/", - headers={{ - "Origin": "https://example.com", - "Access-Control-Request-Method": "GET", - "Access-Control-Request-Headers": "Authorization, Content-Type", - }}, - ) - - assert resp.status_code == 200 - assert resp.headers.get("access-control-allow-origin") == "https://example.com" "# ) } From 8ce603937f6a12f417b019d2cedcb4568bfa5f8d Mon Sep 17 00:00:00 2001 From: Paul Sanders Date: Thu, 14 May 2026 20:30:21 -0400 Subject: [PATCH 3/3] Fix test file imports --- src/fastapi/test_files.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/fastapi/test_files.rs b/src/fastapi/test_files.rs index d97b7260..3aa7e0cc 100644 --- a/src/fastapi/test_files.rs +++ b/src/fastapi/test_files.rs @@ -1383,14 +1383,10 @@ fn create_main_test_file(project_info: &ProjectInfo) -> String { let module = &project_info.module_name(); format!( - r#"import importlib -from unittest.mock import patch + r#"from unittest.mock import patch from loguru import logger -from {module} import main -from {module}.core.config import settings - async def test_http_exception_handler(test_client, normal_user_token_headers, caplog): logger.add(caplog.handler, level="ERROR", format="{{message}}")