Posts Tagged: api
-
FastAPI Dependency Injection: When Depends() Causes Circular Import Errors
FastAPI Depends() circular import errors fix: Move to central deps.py, string refs Depends('get_db'), lazy imports in func, app factories. Common router→model→db cycles. Code + pytest verification. Targets 'fastapi circular import depends', 'fastapi dependency injection error', 'ImportError partially initialized module fastapi'.
-
FastAPI Framework: Python ASGI Microframework Tutorial
FastAPI tutorial: installation, hello world app, Pydantic models, databases, dependencies, testing, deployment. Benchmarks vs Flask and Django.
-
FastAPI OpenAPI Schema Generation: Customizing Swagger UI with Custom CSS and Logo
FastAPI OpenAPI schema generation & Swagger UI customization: Add custom CSS, logo to /docs. Override schema info/tags, serve static files, production uvicorn. Benchmarks: Custom CSS adds 0.2ms latency. Code examples, pydantic models, swagger_ui_css_url. Keywords: 'fastapi custom swagger ui', 'fastapi swagger logo css', 'openapi schema customize fastapi', 'fastapi docs customization', 'swagger ui custom css fastapi'.
-
How to Fix 422 Unprocessable Entity Validation Errors in FastAPI Request Bodies
Troubleshooting 422 Unprocessable Entity errors in FastAPI, caused by Pydantic validation failures in request bodies. Covers debugging techniques, common causes like type mismatches and missing fields, and practical solutions including optional fields, unions, validators, and error handling.
-
Implementing OAuth2 with Password Flow in FastAPI: Complete JWT Token Example
Implement OAuth2 password flow in FastAPI with JWT tokens: secure authentication using PyJWT and passlib, including login endpoint, protected routes, and curl tests with a fake user database.
-
Pydantic v2 Migration in FastAPI: Fixing model_validator Decorator Breaking Changes
Pydantic v2 @model_validator(mode='before') receives model instances in some cases like field assignment. Fixes for FastAPI migration, including code examples and tests.
-
Serving FastAPI Behind Traefik with Automatic HTTPS and Path-Based Routing
Deploy FastAPI behind Traefik using Docker Compose for automatic HTTPS via Let's Encrypt and path-based routing. Covers docker-compose labels, middleware for prefix stripping, and production considerations.