Spaces:
Sleeping
Sleeping
ohhhchank3
commited on
Commit
•
2b33de7
1
Parent(s):
b6f1189
Create model.py
Browse files
model.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pydantic import BaseModel, Field, EmailStr
|
2 |
+
|
3 |
+
class PostSchema(BaseModel):
|
4 |
+
id: int = Field(default=None)
|
5 |
+
title: str = Field(...)
|
6 |
+
content: str = Field(...)
|
7 |
+
|
8 |
+
class Config:
|
9 |
+
schema_extra = {
|
10 |
+
"example": {
|
11 |
+
"title": "Securing FastAPI applications with JWT.",
|
12 |
+
"content": "In this tutorial, you'll learn how to secure your application by enabling authentication using JWT. We'll be using PyJWT to sign, encode and decode JWT tokens...."
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
|
17 |
+
class UserSchema(BaseModel):
|
18 |
+
fullname: str = Field(...)
|
19 |
+
email: EmailStr = Field(...)
|
20 |
+
password: str = Field(...)
|
21 |
+
|
22 |
+
class Config:
|
23 |
+
schema_extra = {
|
24 |
+
"example": {
|
25 |
+
"fullname": "Joe Doe",
|
26 |
+
"email": "joe@xyz.com",
|
27 |
+
"password": "any"
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
class UserLoginSchema(BaseModel):
|
32 |
+
email: EmailStr = Field(...)
|
33 |
+
password: str = Field(...)
|
34 |
+
|
35 |
+
class Config:
|
36 |
+
schema_extra = {
|
37 |
+
"example": {
|
38 |
+
"email": "joe@xyz.com",
|
39 |
+
"password": "any"
|
40 |
+
}
|
41 |
+
}
|