|
| 1 | +# 📘 Assignment: Building REST APIs with FastAPI |
| 2 | + |
| 3 | +## 🎯 Objective |
| 4 | + |
| 5 | +Learn to build a RESTful API using the FastAPI framework, including creating endpoints, handling HTTP methods, and working with request/response models. |
| 6 | + |
| 7 | +## 📝 Tasks |
| 8 | + |
| 9 | +### 🛠️ Create a Todo List API |
| 10 | + |
| 11 | +#### Description |
| 12 | +Build a REST API for managing a todo list with endpoints to create, read, update, and delete todo items. |
| 13 | + |
| 14 | +#### Requirements |
| 15 | +Completed program should: |
| 16 | + |
| 17 | +- Define a Todo model with fields: id, title, description, and completed status |
| 18 | +- Create a GET endpoint to retrieve all todos |
| 19 | +- Create a GET endpoint to retrieve a single todo by ID |
| 20 | +- Create a POST endpoint to add a new todo |
| 21 | +- Create a PUT endpoint to update an existing todo |
| 22 | +- Create a DELETE endpoint to remove a todo |
| 23 | +- Return appropriate HTTP status codes (200, 201, 404, etc.) |
| 24 | +- Use FastAPI's automatic API documentation at /docs |
| 25 | + |
| 26 | + |
| 27 | +### 🛠️ Add Data Validation |
| 28 | + |
| 29 | +#### Description |
| 30 | +Implement request validation using Pydantic models to ensure data integrity. |
| 31 | + |
| 32 | +#### Requirements |
| 33 | +Completed program should: |
| 34 | + |
| 35 | +- Use Pydantic models for request and response validation |
| 36 | +- Validate that title is required and not empty |
| 37 | +- Validate that completed is a boolean value |
| 38 | +- Return clear error messages for invalid input (422 status) |
| 39 | +- Include example values in the API documentation |
0 commit comments