Cơ BảnFastAPI iconFastAPI

Path operation trong FastAPI là gì?

Path operation là function gắn với một HTTP method và path, ví dụ GET /users/{id} hoặc POST /orders. FastAPI đọc type hints từ function parameters để parse path params, query params, body, header, cookie và validate tự động.

Điểm mạnh là route handler vừa là code xử lý request vừa là contract cho OpenAPI docs. Vì vậy type hints và response model nên được viết nghiêm túc, không chỉ để editor autocomplete.

Xem toàn bộ FastAPI cùng filter theo level & chủ đề con.

Mở danh sách FastAPI