Repository navigation
Test with FastAPI 0.146.0 and a server-provided root_path - #13
Closed
joakimnordling wants to merge 1 commit into
Closed
joakimnordling wants to merge 1 commit into
joakimnordling wants to merge 1 commit into
Conversation
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>
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FastAPI 0.146.0 deprecates the
root_pathparameter ofFastAPI()in favour of configuring the server, e.g.fastapi run --root-path /api/v1. Ourtest_root_pathused that parameter, so it now emits aFastAPIDeprecationWarning(aUserWarning, so it isn't hidden by ourignore::DeprecationWarningfilter).Changes
test_root_pathnow gets its root_path from the server (TestClient(app, root_path="/api/v1")), the wayfastapi run --root-pathdoes. The deprecated parameter only ever set that same scope value, so the library code path is unchanged./api/v1/..., which it didn't before.No library code changes; the
fastapi>=0.133.0,<1range 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:
openapi_prefixparameter and**extra. We use neither.root_pathparameter (above).The docs routes still call
get_swagger_ui_html/get_redoc_htmlfromfastapi.applicationswith anopenapi_urlbuilt from the request's root_path, so the patching keeps working unchanged.Testing
uv run invoke testpasses (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