Your API already has real clients using it, but you need to rename a field in the response — edit it directly and the old clients break immediately. The standard fix is versioning: split the routes into /api/v1 and /api/v2 with APIRouter, keep v1 exactly as it is, and put every breaking change into v2 only. This takes 5 minutes and applies whenever your API is public and you don’t control every client.
The Problem
Suppose the /users endpoint returns {“id”: 1, “name”: “Linh”}. Now you want to split name into first_name and last_name, and add email. If you edit it directly, every old client reading the name field gets null or an error — a mobile app that hasn’t updated yet breaks. The problem is that a single URL serves both old and new clients, so every change is a breaking change.
from fastapi import FastAPI
app = FastAPI ( )
@app .…