بنقرة واحدة
add-endpoint
Add a new FastAPI API endpoint. Use when creating new REST API routes for the application.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Add a new FastAPI API endpoint. Use when creating new REST API routes for the application.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | add-endpoint |
| description | Add a new FastAPI API endpoint. Use when creating new REST API routes for the application. |
| argument-hint | <endpoint-name> |
按以下步骤添加新的 FastAPI 端点,以 {endpoint_name} 为例。
在 app/schemas/{endpoint_name}.py 中定义请求/响应模型:
from pydantic import BaseModel
from typing import Optional
class {Name}Request(BaseModel):
"""请求模型"""
field: str
class {Name}Response(BaseModel):
"""响应模型"""
id: str
field: str
在 app/services/{endpoint_name}_service.py 中实现业务逻辑:
from sqlalchemy.orm import Session
class {Name}Service:
def __init__(self, db: Session):
self.db = db
def create(self, data: dict) -> dict:
# 业务逻辑
pass
在 app/api/{endpoint_name}.py 中定义路由:
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.core.security import get_current_user
from app.db.database import get_db
from app.db.models import User
from app.schemas.{endpoint_name} import {Name}Request, {Name}Response
router = APIRouter()
@router.post("/", response_model={Name}Response)
async def create_{endpoint_name}(
request: {Name}Request,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
):
"""创建{name}"""
pass
在 main.py 中注册:
from app.api.{endpoint_name} import router as {endpoint_name}_router
app.include_router({endpoint_name}_router, prefix="/api/{endpoint_name}", tags=["{endpoint_name}"])
在 test/test_{endpoint_name}.py 中编写测试。
get_current_user 鉴权(除非明确公开)HTTPException(status_code=xxx, detail="中文描述")app/api/chat.py 的写法Add a new LLM provider to fusion-api. Use when integrating a new AI model service.
Fusion API 项目架构、技术栈、核心组件总览。Use when you need to understand how the backend works, its architecture, or tech stack.
Quick reference for all API endpoints. Use when you need to know available endpoints, their methods, and purposes.
Debug streaming issues (stop not working, content loss, reconnect problems). Use when SSE streaming has bugs.
查看 dev 服务器 fusion-api 日志。Use when debugging backend issues, checking errors, or tracing request flow.
用 curl 测试 dev 服务器 API 端点。Use to verify API behavior, test streaming, or debug issues end-to-end.