- Call future.result() instead of bare property access in test (#596)
- Catch (ValueError, TypeError) instead of broad Exception in
response model serialization (#597)
- Catch WebSocketDisconnect instead of broad Exception in
websocket chat example (#598)
Closes#596, closes#597, closes#598
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
## About
A few cosmetic adjustments aka. code formatting.
Also validate the outcome on CI/GHA.
Feel free to improve now or later at your disposal.
## Details
The updates are based on using the most recent versions of pyproject-fmt
and ruff.
Specifically, spots marked with `noqa` might need further love, also at
your disposal.
---------
Co-authored-by: Kenneth Reitz <me@kennethreitz.org>
- Include ext/openapi/docs/*.html in package_data so OpenAPI docs
themes (swagger_ui, redoc, rapidoc, elements) ship with the wheel.
Fixes#583.
- Add tests for static file serving and index.html fallback. Fixes#563.
- Bump version to 3.4.1.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Define your API schemas with Pydantic models instead of (or alongside)
YAML docstrings and marshmallow:
from pydantic import BaseModel
class PetIn(BaseModel):
name: str
age: int = 0
class PetOut(BaseModel):
id: int
name: str
age: int
@api.route("/pets", methods=["POST"],
request_model=PetIn, response_model=PetOut)
async def create_pet(req, resp):
data = await req.media()
resp.media = {"id": 1, **data}
Also works with @api.schema("Name") decorator for registering
standalone schema components.
Pydantic models, marshmallow schemas, and YAML docstrings can all
be used together in the same API.
Also: rewrite docs with more prose, restore sidebar logo and links,
add FastAPI acknowledgment, update homepage copy.
161 tests, 95% coverage.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>