41 lines
1.0 KiB
Python

Here's the `user.py` file with Pydantic schemas for user in the `app/api/v1/schemas/` directory:
from typing import Optional
from pydantic import BaseModel, EmailStr
class UserBase(BaseModel):
email: EmailStr
is_active: Optional[bool] = True
is_superuser: bool = False
full_name: Optional[str] = None
class UserCreate(UserBase):
password: str
class UserUpdate(UserBase):
password: Optional[str] = None
class UserInDBBase(UserBase):
id: Optional[int] = None
class Config:
orm_mode = True
class User(UserInDBBase):
pass
class UserInDB(UserInDBBase):
hashed_password: str
Explanation:
1. We import the necessary modules: `typing` for type hints, `pydantic` for defining data models, and `EmailStr` from `pydantic` for email validation.
Note: This file assumes that you have already set up the necessary dependencies and project structure for your FastAPI application. Make sure to import and use these schemas in the appropriate parts of your application, such as the API routes and database models.