FastAPI parses the path, query, headers, cookies and body, and validates them against your type hints and Pydantic models before calling your function.
On failure it returns 422 with a JSON body whose detail is a list of errors, each with the location (loc, such as body and field name), a message (msg) and an error type, so clients can see exactly what to fix.
You can customize the response by registering a handler for RequestValidationError.
Loading…