Skip to content

Commit 603225a

Browse files
author
Jakub Miazek
committed
add auth user pydantic schemas
1 parent d13d5ab commit 603225a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

app/schemas/user.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from uuid import UUID
2+
3+
from pydantic import BaseModel, Field, EmailStr, ConfigDict
4+
5+
config = ConfigDict(from_attributes=True)
6+
7+
8+
# TODO: add pydantic field validator for strong password
9+
class UserSchema(BaseModel):
10+
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")
15+
16+
17+
class UserResponse(BaseModel):
18+
uuid: UUID = Field(title="User’s id", description="User’s id")
19+
email: EmailStr = Field(title="User’s email", description="User’s email")
20+
first_name: str = Field(title="User’s first name", description="User’s first name")
21+
last_name: str = Field(title="User’s last name", description="User’s last name")
22+
access_token: str = Field(title="User’s token", description="User’s token")
23+
24+
25+
class TokenResponse(BaseModel):
26+
access_token: str = Field(title="User’s access token", description="User’s access token")
27+
token_type: str = Field(title="User’s token type", description="User’s token type")
28+
29+
30+
class UserLogin(BaseModel):
31+
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")
34+

0 commit comments

Comments
 (0)