1. Aprende
  2. /
  3. Cursos
  4. /
  5. Introduction to FastAPI

Connected

Ejercicio

Pydantic model

You've been asked to create an API endpoint that manages items in inventory. To get started, create a Pydantic model for Items that has attributes name, quantity, and expiration.

Instrucciones

100 XP
  • Import date from datetime and BaseModel from pydantic.
  • Create a Pydantic model for Item.
  • Fill in the following fields correctly: name (string), quantity (integer, optional, default 0), and expiration (date, optional, default None).