require-constrained-api-integer
Declare numeric bounds for scalar integer FastAPI request parameters.
Why
A bare integer request parameter accepts negative and arbitrarily large values even when the service expects a bounded page size or ordinal.
Fix
Use PositiveInt, NonNegativeInt or a domain Annotated type, or declare the appropriate Query/Path bounds. Keep signed and sentinel contracts explicit with a reasoned local exception.
Examples
from fastapi import APIRouter
router = APIRouter()
@router.get("/versions")def versions(limit: int = 25): return limitfrom fastapi import APIRouterfrom pydantic import PositiveInt
router = APIRouter()
@router.get("/versions")def versions(limit: PositiveInt = 25): return limit