FastAPI: Use Enums for Path Parameters — Endpoints That Only Accept Valid Values in 5 Minutes
Many APIs have path parameters that only accept a few fixed values — an order status, for example. Declare the parameter as a str Enum and FastAPI rejects unknown values with a 422 on its own, generates docs with the list of choices, and removes the if/else branch for invalid values.

![[pt-BR] Dominando Enums em Rust: Do Básico ao Avançado para Pythonistas](https://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdesbravandorust.com.br%2F..%2Fimgs%2Fdevto-covers%2F0007.jpg)



