Skip to content

Commit f27fd9b

Browse files
committed
Fixed docs, added example support
1 parent 26ed45f commit f27fd9b

18 files changed

Lines changed: 76 additions & 41 deletions

docs/advanced/architecture.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -253,21 +253,21 @@ class RequestData:
253253
"""Unified request data container"""
254254
def __init__(
255255
self,
256-
path_params: dict[str, Any],
257-
query_params: dict[str, Any],
258-
headers: dict[str, str],
259-
cookies: dict[str, str],
260-
body: dict[str, Any] | None = None,
261-
form_data: dict[str, Any] | None = None,
262-
files: dict[str, Any] | None = None,
256+
path_params: dict[str, Any] = None,
257+
query_params: dict[str, Any] = None,
258+
headers: dict[str, str] = None,
259+
cookies: dict[str, str] = None,
260+
body: Any = None,
261+
form_data: dict[str, Any] = None,
262+
files: dict[str, FileUpload | list[FileUpload]] = None,
263263
):
264-
self.path_params = path_params
265-
self.query_params = query_params
266-
self.headers = headers
267-
self.cookies = cookies
264+
self.path_params = path_params or {}
265+
self.query_params = query_params or {}
266+
self.headers = headers or {}
267+
self.cookies = cookies or {}
268268
self.body = body
269-
self.form_data = form_data
270-
self.files = files
269+
self.form_data = form_data or {}
270+
self.files = files or {}
271271
```
272272

273273
**Extractor Interface:**

docs/advanced/architecture_quick_reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ sequenceDiagram
8383
| `BaseRouter` | `fastopenapi/core/router.py` | Route registration, OpenAPI generation |
8484
| `BaseAdapter` | `fastopenapi/routers/base.py` | Request pipeline orchestration |
8585
| `FrameworkRouter` | `fastopenapi/routers/{framework}/` | Framework integration (3 methods) |
86-
| `RequestDataExtractor` | `fastopenapi/routers/extractors.py` | Extract data from requests |
86+
| `BaseRequestDataExtractor` / `BaseAsyncRequestDataExtractor` | `fastopenapi/routers/extractors.py` | Extract data from requests (sync / async) |
8787
| `ParameterResolver` | `fastopenapi/resolution/resolver.py` | Parameter validation |
8888
| `DependencyResolver` | `fastopenapi/core/dependency_resolver.py` | Dependency injection |
8989
| `ResponseBuilder` | `fastopenapi/response/builder.py` | Response serialization |

docs/advanced/custom_routers.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,10 @@ class RouteInfo:
427427
Wrapper for framework request (from `fastopenapi.routers.common`):
428428

429429
```python
430+
@dataclass(slots=True, frozen=True)
430431
class RequestEnvelope:
431-
request: Any # Framework's request object
432-
path_params: dict # Path parameters extracted by framework
432+
path_params: dict[str, str] # Path parameters extracted by framework
433+
request: Any | None # Framework's request object
433434
```
434435

435436
### Response

docs/advanced/openapi_customization.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ The router constructor supports the following parameters:
3434
| `docs_url` | str \| None | "/docs" | Swagger UI URL |
3535
| `redoc_url` | str \| None | "/redoc" | ReDoc URL |
3636
| `openapi_url` | str \| None | "/openapi.json" | OpenAPI schema URL |
37-
38-
> **Note:** Setting any URL to `None` disables all documentation endpoints at once.
3937
| `openapi_version` | str | "3.0.0" | OpenAPI specification version |
4038
| `security_scheme` | SecuritySchemeType \| None | BEARER_JWT | Default security scheme |
4139

40+
> **Note:** Setting any URL to `None` disables all documentation endpoints at once.
41+
4242
## Tags
4343

4444
Organize endpoints with tags:
@@ -242,7 +242,7 @@ def list_users(
242242
### API Key in Header
243243

244244
```python
245-
from fastopenapi.core.constants import SecuritySchemeType
245+
from fastopenapi import SecuritySchemeType
246246

247247
router = FlaskRouter(
248248
app=app,

docs/api_reference/routers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ if __name__ == "__main__":
469469
Set the security scheme for OpenAPI documentation:
470470

471471
```python
472-
from fastopenapi.core.constants import SecuritySchemeType
472+
from fastopenapi import SecuritySchemeType
473473

474474
# Bearer JWT (default)
475475
router = FlaskRouter(

docs/community/contributing.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ pre-commit run --all-files
8484
## Documentation
8585

8686
If your change affects public APIs or behavior, update the relevant documentation:
87-
- `docs/en/`
88-
- If possible, update other languages too (optional)
87+
- `docs/`
8988

9089
---
9190

docs/examples/authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ from pydantic import BaseModel
1212
from datetime import datetime, timedelta
1313
import secrets
1414
import hashlib
15-
from fastopenapi import Header, Body, Depends, Security
15+
from fastopenapi import Header, Depends, Security
1616
from fastopenapi.routers import FlaskRouter
1717
from fastopenapi.errors import AuthenticationError, ResourceConflictError
1818

docs/frameworks/django.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ FastOpenAPI automatically converts common Django exceptions:
797797
# These are automatically handled:
798798
# - Http404 -> 404 error
799799
# - PermissionDenied -> 403 error
800-
# - SuspiciousOperation -> 400 error
800+
# - BadRequest -> 400 error
801801
```
802802

803803
## Next Steps

docs/frameworks/flask.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Flask uses `<type:name>` syntax, but FastOpenAPI converts `{name}` automatically
4848
def get_user(user_id: int):
4949
return {"user_id": user_id}
5050

51-
# Both generate the same Flask route: /users/<int:user_id>
51+
# Both generate the same Flask route: /users/<user_id>
5252
```
5353

5454
## Request Data

docs/frameworks/overview.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ FastOpenAPI supports 8 popular Python web frameworks. This guide helps you choos
44

55
## Supported Frameworks
66

7-
| Framework | Type | Async | Python 3.10+ | Best For |
8-
|-----------|------|-------|--------------|----------|
9-
| **Flask** | WSGI | No | Yes | Traditional web apps, simple APIs |
10-
| **Django** | WSGI/ASGI | Both | Yes | Full-featured web applications |
11-
| **Starlette** | ASGI | Yes | Yes | Modern async APIs, high performance |
12-
| **Quart** | ASGI | Yes | Yes | Async Flask alternative |
13-
| **AIOHTTP** | ASGI | Yes | Yes | Async HTTP client/server |
14-
| **Sanic** | ASGI | Yes | Yes | Speed-focused async framework |
15-
| **Falcon** | WSGI/ASGI | Both | Yes | Minimalist APIs, microservices |
16-
| **Tornado** | Async | Yes | Yes | Long-lived connections, WebSockets |
7+
| Framework | Async | Python 3.10+ | Best For |
8+
|-----------|-------|--------------|----------|
9+
| **Flask** | No | Yes | Traditional web apps, simple APIs |
10+
| **Django** | Both | Yes | Full-featured web applications |
11+
| **Starlette** | Yes | Yes | Modern async APIs, high performance |
12+
| **Quart** | Yes | Yes | Async Flask alternative |
13+
| **AIOHTTP** | Yes | Yes | Async HTTP client/server |
14+
| **Sanic** | Yes | Yes | Speed-focused async framework |
15+
| **Falcon** | Both | Yes | Minimalist APIs, microservices |
16+
| **Tornado** | Yes | Yes | Long-lived connections, WebSockets |
1717

1818
## Quick Comparison
1919

@@ -329,7 +329,7 @@ def get_user(user_id: int):
329329
| **Form Handling** | Extension | Yes | Yes | Yes | No | Yes | No | Yes |
330330
| **Session Management** | Extension | Yes | Middleware | Extension | No | Extension | No | Yes |
331331
| **Template Engine** | Jinja2 | Django Templates | Jinja2 | Jinja2 | Jinja2 | Jinja2 | No | Native |
332-
| **Deployment** | WSGI | WSGI/ASGI | ASGI | ASGI | ASGI | ASGI | WSGI/ASGI | ASGI |
332+
| **Deployment** | Sync | Sync/Async | Async | Async | Async | Async | Sync/Async | Async |
333333

334334
*Django and Falcon support both sync and async
335335

0 commit comments

Comments
 (0)