-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschemas.py
66 lines (51 loc) · 1.62 KB
/
schemas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#this schema is to help us validate the data
from pydantic import BaseModel
from typing import Optional
class SignUpModel(BaseModel):
id: Optional[int]
username: str
email: str
password: str
is_staff:Optional[bool]
is_active: Optional[bool]
#orders = relationship("Order", back_populates="user")
#sqlalchemy is the orm in this project
class Config:
orm_mode = True
schema_extra = {
"example": {
"username": "test",
"email": "[email protected]",
"password": "password",
"is_staff": False,
"is_active": True,
}
}
class Settings(BaseModel):
authjwt_secret_key: str='a0076b92217c27dd15701b85280212aa99fb52c0c48011a42b7f8081eed92a97' #to generate this toke, open terminal and type python, then import secrets, then secrets.token_hex()
class LoginModel(BaseModel):
username: str
password: str
class OrderModel(BaseModel):
id: Optional[int]
quantity: int
order_status: Optional[str]="PENDING"
pizza_size: Optional[str]="SMALL"
user_id: Optional[int]
class Config:
orm_mode = True
schema_extra = {
"example": {
"quantity": 2,
"pizza_size": "LARGE"
}
}
class OrderStatusModel(BaseModel):
order_status: Optional[str]="PENDING"
class Config:
orm_mode = True
schema_extra = {
"example": {
"order_status": "PENDING"
}
}