FastAPI Self Hosting Docs
一个用于 FastAPI 应用程序的自托管文档解决方案,提供本地化的 Swagger UI 和 ReDoc 文档界面。
特性
- 🚀 自托管文档: 所有文档资源都托管在应用程序内部,无需外部依赖
- 📖 Swagger UI: 提供交互式的 API 文档界面
- 📋 ReDoc: 提供美观的 API 文档展示
- 🎨 自定义样式: 包含自定义的 favicon 和样式
- 🔧 简单集成: 只需一行代码即可替换标准 FastAPI 应用
安装
pip install fastapi-self-hosting-docs
快速开始
基本用法
import uvicorn
from fastapi import FastAPI
import fastapi_self_hosting_docs
app = FastAPI(
docs_url=None,
redoc_url=None
)
fastapi_self_hosting_docs.mount(app)
# 启动应用
uvicorn.run(app)
Swagger UI
ReDoc
文档访问
启动应用后,可以通过以下地址访问文档:
- Swagger UI:
http://127.0.0.1:8000/docs - ReDoc:
http://127.0.0.1:8000/redoc
与标准 FastAPI 的区别
| 特性 | 标准 FastAPI | FastAPI Self Hosting Docs |
|---|---|---|
| 文档资源 | 外部 CDN | 本地托管 |
| Swagger UI | /docs |
/docs |
| ReDoc | /redoc |
/redoc |
| 依赖 | 无额外依赖 | 仅需 fastapi |
| 自定义 favicon | 不支持 | 支持 |
许可证
本项目采用 Apache 2.0 许可证。详情请参阅 LICENSE 文件。
贡献
欢迎提交 Issue 和 Pull Request!
Metadata
Release files for fastapi-self-hosting-docs 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastapi_self_hosting_docs-0.8.0.tar.gz | 1.1 MB | Without provenance | Details for fastapi_self_hosting_docs-0.8.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastapi_self_hosting_docs-0.8.0-py3-none-any.whl | Python 3 | none | any | Details for fastapi_self_hosting_docs-0.8.0-py3-none-any.whl |
Total release size: 1.8 MB
Release files / fastapi_self_hosting_docs-0.8.0.tar.gz
| Download URL | fastapi_self_hosting_docs-0.8.0.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58950e8f7a267225242219831aa3148ff5874f669594638950428299dbc0a927
|
|
BLAKE2b-256 checksum How to use checksums |
e6f235aaae5c82495a2141367997cb487d93a95c7ee17a36cc1eca9215f25438
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.10
|
Release files / fastapi_self_hosting_docs-0.8.0-py3-none-any.whl
| Download URL | fastapi_self_hosting_docs-0.8.0-py3-none-any.whl |
|---|---|
| Size | 747.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eed54d9c11f4712dee6459559e677a74d1a8930a95414395a39f13b7b605fe0e
|
|
BLAKE2b-256 checksum How to use checksums |
63a281c683cb2ce9e7ffdfa05a25f8ffda95c50dc5e6cceaf93c8205b428b8c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.10
|
Security for fastapi-self-hosting-docs 0.8.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.