fastapi-offline is a Python library that enables FastAPI applications to serve their interactive documentation (Swagger UI and Redoc) without relying on external Content Delivery Networks (CDNs). It bundles the necessary static assets locally, making it suitable for environments with restricted internet access or for improved reliability. The library is actively maintained, with frequent releases (currently v1.7.6) to vendor new dependencies and ensure compatibility with the latest Python and FastAPI versions.
pip install fastapi-offlineVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a basic FastAPI application using `FastAPIOffline`. Simply import `FastAPIOffline` and instantiate it instead of `FastAPI`. The interactive documentation (Swagger UI and ReDoc) will then be served from local assets, making them available offline. Any parameters passed to `FastAPIOffline()` (except `docs_url`, `redoc_url`, `favicon_url`, and `static_url`) are forwarded to the underlying `FastAPI` instance.
Ensure your project uses Python 3.8 or newer. Upgrade your Python environment to a currently supported version.
Customize `docs_url`, `redoc_url`, `favicon_url`, and `static_url` directly through the `FastAPIOffline` constructor. Other `FastAPI` parameters are passed through as expected.
Always try to keep `fastapi-offline` updated to a version compatible with your `fastapi` installation. Check the release notes of `fastapi-offline` for any specific FastAPI version tracking information.
Update `fastapi-offline` to the latest version (`pip install --upgrade fastapi-offline`). If you use a custom `static_url`, ensure it's correctly configured to point to the `fastapi-offline`'s served static files (default is `/static-offline-docs`).
Install the package using pip: `pip install fastapi-offline`.
Ensure you are consistently instantiating `FastAPIOffline` and not directly manipulating FastAPI's internal documentation rendering. Check that both `fastapi-offline` and `fastapi` are reasonably up-to-date and compatible versions.