FastAPI framework with Pydantic v2 patterns, PII sanitisation, and practical workflows
fastapi dev app/main.pyThis enables auto-reload. For production, use fastapi run app/main.py.
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8000/docs
# Expect: 200curl -s http://127.0.0.1:8000/openapi.json | python -m json.toolConfirm all expected endpoints and response models appear.
# GET example
curl -s http://127.0.0.1:8000/health
# POST example
curl -s -X POST http://127.0.0.1:8000/items/ \
-H "Content-Type: application/json" \
-d '{"name": "Widget", "price": 9.99}'pytest -v| Symptom | Cause | Fix |
|---|---|---|
Address already in use | Port 8000 occupied | lsof -i :8000 then kill the process, or use --port 8001 |
ModuleNotFoundError | Missing dependency | pip install "fastapi[standard]" |
No module named 'app' | Wrong working directory | cd to the project root containing app/ |
| 422 on POST | Request body doesn't match schema | Check the schema at /docs and fix the payload |
lifespan error | Mixing on_startup/on_shutdown with lifespan | Use only lifespan — remove deprecated event handlers |
tessl i maria/fastapi@0.1.0