-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschemas.py
48 lines (41 loc) · 871 Bytes
/
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
from typing import List
from pydantic import BaseModel
# Article inside UserDisplay
class Article(BaseModel):
title: str
content: str
published: bool
class Config():
orm_mode = True
class UserBase(BaseModel):
username: str
email: str
password: str
class UserDisplay(BaseModel):
username: str
email: str
items: List[Article] = []
class Config:
orm_mode = True
# User inside ArticleDisplay
class User(BaseModel):
id: int
username: str
class Config():
orm_mode = True
class ArticleBase(BaseModel):
title: str
content: str
published: bool
creator_id: int
class ArticleDisplay(BaseModel):
title: str
content: str
published: bool
user: User
class Config:
orm_mode = True
class ProductBase(BaseModel):
title: str
description: str
price: float