Skip to content

Test with FastAPI 0.146.0 and a server-provided root_path - #13

Closed
joakimnordling wants to merge 1 commit into
ioxiocom:mainfrom
joakimnordling:chore/fastapi-0.146
Closed

joakimnordling wants to merge 1 commit into
ioxiocom:mainfrom
joakimnordling:chore/fastapi-0.146

Conversation

@joakimnordling

Copy link
Copy Markdown
Contributor

FastAPI 0.146.0 deprecates the root_path parameter of FastAPI() in favour of configuring the server, e.g. fastapi run --root-path /api/v1. Our test_root_path used that parameter, so it now emits a FastAPIDeprecationWarning (a UserWarning, so it isn't hidden by our ignore::DeprecationWarning filter).

Changes

  • test_root_path now gets its root_path from the server (TestClient(app, root_path="/api/v1")), the way fastapi run --root-path does. The deprecated parameter only ever set that same scope value, so the library code path is unchanged.
  • The test now also checks that the static files load from under /api/v1/..., which it didn't before.
  • The locked FastAPI goes from 0.143.0 to 0.146.0.

No library code changes; the fastapi>=0.133.0,<1 range stays as it is.

FastAPI releases reviewed

0.143.4, 0.143.5, 0.144.0, 0.145.0 and 0.146.0 came out on 2026-10-18. Only two touch what we use:

  • 0.145.0 removes the deprecated openapi_prefix parameter and **extra. We use neither.
  • 0.146.0 deprecates the root_path parameter (above).

The docs routes still call get_swagger_ui_html / get_redoc_html from fastapi.applications with an openapi_url built from the request's root_path, so the patching keeps working unchanged.

Testing

uv run invoke test passes (pre-commit, mypy, 15 tests with no warnings, uv audit).

CI only tests the locked FastAPI version, so I also checked the docs HTML and static files with a server-provided root_path by hand on FastAPI 0.133.0 + Starlette 0.40.0, 0.133.0 + 1.7.0, 0.138.0 + 0.46.0, 0.143.0 + 1.7.0 and 0.146.0 + 1.7.0. All passed.

🤖 Generated with Claude Code

FastAPI 0.146.0 deprecates the root_path parameter of FastAPI() in favour of
configuring the server, e.g. `fastapi run --root-path /api/v1`. Switch
test_root_path to a root_path set by the server, which is the same scope value
the parameter used to set, and also check the static files load from under
the root_path.

Bump the locked FastAPI to 0.146.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joakimnordling

Copy link
Copy Markdown
Contributor Author

Superseded by #14, which includes these changes together with the Swagger UI 5.33.3 update, the dev tool updates and the 0.3.1 version bump.

@joakimnordling
joakimnordling deleted the chore/fastapi-0.146 branch October 18, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant