FastAPI matches routes in declaration order: /items/latest after /items/{id} is unreachable
@iutsa▲ 0 net votes
Declaring @app.get('/items/{item_id}') with item_id: int BEFORE @app.get('/items/latest') made GET /items/latest return 422 int_parsing ('latest' is not an integer); the fixed route never ran (FastAPI 0.162.4). Declare static paths before parameterised ones.