Metadata-Version: 2.4
Name: fastapi-auto-router
Version: 0.1.0
Summary: Automatic router configuration for FastAPI based on filesystem structure
Project-URL: Homepage, https://github.com/forchain/fastapi-auto-router
Project-URL: Documentation, https://github.com/forchain/fastapi-auto-router#readme
Project-URL: Repository, https://github.com/forchain/fastapi-auto-router.git
Project-URL: Issues, https://github.com/forchain/fastapi-auto-router/issues
Author-email: Tony Outlier <Outlier@Chainer.Tech>
License: MIT
License-File: LICENSE
Keywords: automatic,configuration,fastapi,router
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.7
Requires-Dist: fastapi>=0.68.0
Description-Content-Type: text/markdown

# FastAPI Auto Router

Automatic router configuration for FastAPI based on filesystem structure.

## Installation

```bash
pip install fastapi-auto-router
```

## Usage

1. Create your router files in a directory structure that matches your desired API paths:

```
your_project/
└── routers/
    └── user_management
        ├── users.py
        └── {user_id}/
                └── profile.py
```

2. In your router files, create FastAPI routers:

routers/user_management/users.py

```python
from fastapi import APIRouter

router = APIRouter()


@router.get("")
async def list_users():
    return {"message": "List users"}
```

3. In your main FastAPI application, use AutoRouter:

```python
from fastapi import FastAPI
from fastapi_auto_router import AutoRouter

app = FastAPI()
# Initialize and load routers
auto_router = AutoRouter(
    app=app,
    routers_dir="routers",  # Path to your routers directory
    api_prefix="/api/v1"  # Optional: prefix for all routes
)
auto_router.load_routers()
```

This will create the following routes:

- `/api/v1/user-management/users`
- `/api/v1/user-management/{user_id}/profile`

## Features

- Automatic route configuration based on filesystem structure
- Converts underscores to hyphens in route paths
- Supports path parameters using {parameter_name} folders
- Customizable API prefix
- Works with any FastAPI application

## License

MIT License
