fastapi-router-py
Generate FastAPI Router Templates with Authentication
Building REST APIs requires consistent router patterns with authentication and proper responses. This skill generates production-ready FastAPI routers following established conventions.
تنزيل ZIP المهارة
رفع في Claude
اذهب إلى Settings → Capabilities → Skills → Upload skill
فعّل وابدأ الاستخدام
اختبرها
استخدام "fastapi-router-py". Create a router for 'Project' resource with required authentication
النتيجة المتوقعة:
Generated router with POST, GET, PUT, DELETE endpoints, User = Depends(get_current_user_required) dependency, response_model configuration, and HTTP_201_CREATED/HTTP_204_NO_CONTENT status codes
استخدام "fastapi-router-py". Add optional auth to existing endpoint
النتيجة المتوقعة:
Endpoint updated with current_user: Optional[User] = Depends(get_current_user) allowing anonymous access with optional user context
التدقيق الأمني
آمنStatic analysis flagged 17 patterns (external_commands and weak cryptographic algorithm), but all are false positives. The file is a markdown documentation template containing Python code examples in fenced blocks, not executable code. No actual shell execution or cryptographic operations exist.
درجة الجودة
ماذا يمكنك بناءه
Rapid API Endpoint Creation
Quickly scaffold new resource endpoints with standard CRUD operations and authentication.
Consistent Router Patterns
Ensure all team members follow the same router structure with proper response models and status codes.
Learning FastAPI Best Practices
Study generated templates to understand authentication dependencies and response model patterns.
جرّب هذه الموجهات
Create a FastAPI router for a 'Product' resource with standard CRUD endpoints. Use 'product' as the snake_case name and 'products' as the plural form.
Generate a FastAPI router for 'Task' management that requires authentication for all endpoints. Include proper 401 handling for unauthorized requests.
Create a FastAPI router for 'Article' where listing is public but create, update, and delete require authentication. Show both dependency patterns.
Generate a complete router for 'Comment' resource with: (1) router file in src/backend/app/routers/, (2) mounting code for main.py, (3) Pydantic models for request/response, (4) service layer stub.
أفضل الممارسات
- Always define response_model to ensure type safety and filter sensitive fields
- Use appropriate HTTP status codes: 201 for creation, 204 for deletion, 200 for reads
- Separate optional and required authentication dependencies clearly in function signatures
تجنب
- Avoid mixing optional and required auth in the same endpoint - use separate endpoints
- Do not skip response_model on endpoints returning sensitive user data
- Never return raw database models directly without Pydantic serialization