{"id":7216,"library":"fastapi-offline","title":"FastAPI Offline Docs","description":"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.","status":"active","version":"1.7.6","language":"en","source_language":"en","source_url":"https://github.com/turettn/fastapi_offline","tags":["FastAPI","offline","documentation","Swagger UI","Redoc","API","web framework"],"install":[{"cmd":"pip install fastapi-offline","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core framework that fastapi-offline extends to provide offline documentation. While not a direct runtime dependency of the package itself, it's the fundamental framework this library is designed to work with.","package":"fastapi","optional":false},{"reason":"ASGI server commonly used to run FastAPI applications.","package":"uvicorn","optional":true}],"imports":[{"note":"When using `fastapi-offline`, you should instantiate `FastAPIOffline` instead of `FastAPI` to enable offline documentation features.","wrong":"from fastapi import FastAPI","symbol":"FastAPIOffline","correct":"from fastapi_offline import FastAPIOffline"}],"quickstart":{"code":"from fastapi_offline import FastAPIOffline\nimport uvicorn\n\napp = FastAPIOffline(\n    title=\"My Offline API\",\n    description=\"A simple API with offline docs\"\n)\n\n@app.get(\"/\")\nasync def read_root():\n    return {\"message\": \"Hello Offline World!\"}\n\n@app.get(\"/items/{item_id}\")\nasync def read_item(item_id: int):\n    return {\"item_id\": item_id}\n\n# To run this app, save it as main.py and execute: uvicorn main:app --reload\n# Then open http://127.0.0.1:8000/docs or http://127.0.0.1:8000/redoc in your browser.","lang":"python","description":"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."},"warnings":[{"fix":"Ensure your project uses Python 3.8 or newer. Upgrade your Python environment to a currently supported version.","message":"Older Python versions are no longer supported or tested. Releases starting from v1.7.0 and v1.7.4 explicitly stopped testing on EOL Python versions (e.g., 3.7 and 3.9).","severity":"breaking","affected_versions":"<1.7.0 (for Python 3.7), <1.7.4 (for Python 3.9)"},{"fix":"Customize `docs_url`, `redoc_url`, `favicon_url`, and `static_url` directly through the `FastAPIOffline` constructor. Other `FastAPI` parameters are passed through as expected.","message":"The `FastAPIOffline` constructor handles `docs_url`, `redoc_url`, `favicon_url`, and `static_url` parameters differently than a standard `FastAPI` app. Attempting to set these directly on the underlying `FastAPI` instance or expecting default FastAPI behavior for these specific URLs might lead to unexpected results.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"Compatibility issues may arise if `fastapi-offline` is significantly outdated compared to your `fastapi` version. `fastapi-offline`'s releases often include updates to the bundled Swagger UI and Redoc assets to track changes in FastAPI's behavior and dependencies.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"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`).","cause":"The `fastapi-offline` version is too old for the `fastapi` version, leading to incompatible bundled assets, or a custom `static_url` is misconfigured.","error":"Documentation UI (Swagger/Redoc) not loading or showing old content in browser."},{"fix":"Install the package using pip: `pip install fastapi-offline`.","cause":"The `fastapi-offline` package is not installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'fastapi_offline'"},{"fix":"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.","cause":"This error often occurs when `fastapi-offline` is intended to manage the documentation routes, but internal FastAPI functions are being called directly or implicitly in a way that conflicts with `fastapi-offline`'s approach, possibly due to a version mismatch.","error":"AttributeError: 'FastAPI' object has no attribute 'get_swagger_ui_html' (or similar internal doc-related FastAPI errors)."}]}