Performance: Body with multiple parameters
MEDIUM IMPACT
This affects the server response time, impacting how fast the client receives and renders data.
from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class Item(BaseModel): name: str description: str price: float @app.post("/items/") async def create_item(item: Item): return item
from fastapi import FastAPI, Body app = FastAPI() @app.post("/items/") async def create_item(name: str = Body(...), description: str = Body(...), price: float = Body(...)): return {"name": name, "description": description, "price": price}
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple Body Parameters | N/A (server-side) | N/A | N/A | [X] Bad |
| Single Pydantic Model Body | N/A (server-side) | N/A | N/A | [OK] Good |