Skip to content

fix: honor root_path in offline-docs redoc handler#89

Merged
lesnik512 merged 2 commits into
mainfrom
fix/crit-1-redoc-root-path
May 31, 2026
Merged

fix: honor root_path in offline-docs redoc handler#89
lesnik512 merged 2 commits into
mainfrom
fix/crit-1-redoc-root-path

Conversation

@lesnik512
Copy link
Copy Markdown
Member

@lesnik512 lesnik512 commented May 31, 2026

Summary

  • Redoc handler in enable_offline_docs now reads root_path from the ASGI scope and prefixes both redoc_js_url and openapi_url, matching the existing swagger handler pattern.
  • Existing test_fastapi_offline_docs_root_path extended to fetch redoc and assert both URLs carry the root_path prefix. Test fails on main, passes on this branch.

Closes CRIT-1 and TEST-1 from an internal audit of the codebase.

Test plan

  • just test -- tests/test_fastapi_offline_docs.py -v — three tests pass.
  • just test — full suite passes (79/79).
  • just lint — clean (eof-fixer, ruff format, ruff check, ty check).
  • Reviewer: confirm the diff matches the swagger handler's root_path pattern.

🤖 Generated with Claude Code

lesnik512 and others added 2 commits May 31, 2026 23:05
Sequences criticals + design issues from the audit into 7 small,
dependency-ordered PRs with locked decisions per chunk. Refactor
opportunities and low-priority items deferred to a future planning pass.
Excluded from the mkdocs site like the parent audit doc.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The swagger handler in enable_offline_docs already reads root_path from
the ASGI scope and prefixes asset/OpenAPI URLs. The redoc handler did
not, so redoc 404'd on its JS and OpenAPI spec when the FastAPI app
ran behind a reverse proxy. Mirror the swagger pattern: take Request,
read root_path, prefix both redoc_js_url and openapi_url.

Extends test_fastapi_offline_docs_root_path to fetch redoc and assert
both URLs carry the prefix — the test fails on the prior code.

Closes CRIT-1, TEST-1 from the audit.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
lite_bootstrap/helpers/fastapi_helpers.py 100.00% <100.00%> (ø)
tests/test_fastapi_offline_docs.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lesnik512 lesnik512 self-assigned this May 31, 2026
@lesnik512 lesnik512 merged commit 7c5eb90 into main May 31, 2026
8 checks passed
@lesnik512 lesnik512 deleted the fix/crit-1-redoc-root-path branch May 31, 2026 20:25
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