11from uuid import UUID
22
3- from pydantic import BaseModel , Field , EmailStr , ConfigDict
3+ from pydantic import BaseModel , Field , EmailStr , ConfigDict , SecretStr
44
55config = ConfigDict (from_attributes = True )
66
77
88# TODO: add pydantic field validator for strong password
99class UserSchema (BaseModel ):
1010 model_config = config
11- email : EmailStr = Field (title = "User’s email" , description = "User’s email" )
12- first_name : str = Field (title = "User’s first name" , description = "User’s first name" )
13- last_name : str = Field (title = "User’s last name" , description = "User’s last name" )
14- password : str = Field (title = "User’s password" , description = "User’s password" )
11+ email : EmailStr = Field (title = "User’s email" , description = "User’s email" , examples = [ "john@domain.com" ] )
12+ first_name : str = Field (title = "User’s first name" , description = "User’s first name" , examples = [ "John" ] )
13+ last_name : str = Field (title = "User’s last name" , description = "User’s last name" , examples = [ "Doe" ] )
14+ password : SecretStr = Field (title = "User’s password" , description = "User’s password" , examples = [ "@SuperSecret123" ] )
1515
1616
1717class UserResponse (BaseModel ):
@@ -29,5 +29,5 @@ class TokenResponse(BaseModel):
2929
3030class UserLogin (BaseModel ):
3131 model_config = config
32- email : EmailStr = Field (title = "User’s email" , description = "User’s email" )
33- password : str = Field (title = "User’s password" , description = "User’s password" )
32+ email : EmailStr = Field (title = "User’s email" , description = "User’s email" , examples = [ "john@domain.com" ] )
33+ password : SecretStr = Field (title = "User’s password" , description = "User’s password" , examples = [ "@SuperSecret123" ] )
0 commit comments