delete-route-returns-no-content
FastAPI DELETE routes declare status code 204 No Content.
Why
Without an explicit 204, FastAPI answers a DELETE with 200 and a JSON null body. Generated clients then type the result as nullable data, and API routes disagree on what a successful removal returns.
Fix
Declare status_code=204 (or status.HTTP_204_NO_CONTENT) on the DELETE route and return None.
Examples
from fastapi import APIRouter
router = APIRouter()
@router.delete("/keys/{key_id}")async def revoke(key_id: str) -> None: return Nonefrom fastapi import APIRouter, status
router = APIRouter()
@router.delete("/keys/{key_id}", status_code=status.HTTP_204_NO_CONTENT)async def revoke(key_id: str) -> None: return None