♻ Move project source files to top level from src, update Sentry dependency (#630)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
4
backend/app/schemas/__init__.py
Normal file
4
backend/app/schemas/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from .item import Item, ItemCreate, ItemInDB, ItemUpdate
|
||||
from .msg import Msg
|
||||
from .token import Token, TokenPayload
|
||||
from .user import User, UserCreate, UserInDB, UserUpdate
|
35
backend/app/schemas/item.py
Normal file
35
backend/app/schemas/item.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
|
||||
# Shared properties
|
||||
class ItemBase(BaseModel):
|
||||
title: str | None = None
|
||||
description: str | None = None
|
||||
|
||||
|
||||
# Properties to receive on item creation
|
||||
class ItemCreate(ItemBase):
|
||||
title: str
|
||||
|
||||
|
||||
# Properties to receive on item update
|
||||
class ItemUpdate(ItemBase):
|
||||
pass
|
||||
|
||||
|
||||
# Properties shared by models stored in DB
|
||||
class ItemInDBBase(ItemBase):
|
||||
id: int
|
||||
title: str
|
||||
owner_id: int
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
# Properties to return to client
|
||||
class Item(ItemInDBBase):
|
||||
pass
|
||||
|
||||
|
||||
# Properties properties stored in DB
|
||||
class ItemInDB(ItemInDBBase):
|
||||
pass
|
5
backend/app/schemas/msg.py
Normal file
5
backend/app/schemas/msg.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class Msg(BaseModel):
|
||||
msg: str
|
10
backend/app/schemas/token.py
Normal file
10
backend/app/schemas/token.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class Token(BaseModel):
|
||||
access_token: str
|
||||
token_type: str
|
||||
|
||||
|
||||
class TokenPayload(BaseModel):
|
||||
sub: int | None = None
|
35
backend/app/schemas/user.py
Normal file
35
backend/app/schemas/user.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from pydantic import BaseModel, ConfigDict, EmailStr
|
||||
|
||||
|
||||
# Shared properties
|
||||
class UserBase(BaseModel):
|
||||
email: EmailStr | None = None
|
||||
is_active: bool | None = True
|
||||
is_superuser: bool = False
|
||||
full_name: str | None = None
|
||||
|
||||
|
||||
# Properties to receive via API on creation
|
||||
class UserCreate(UserBase):
|
||||
email: EmailStr
|
||||
password: str
|
||||
|
||||
|
||||
# Properties to receive via API on update
|
||||
class UserUpdate(UserBase):
|
||||
password: str | None = None
|
||||
|
||||
|
||||
class UserInDBBase(UserBase):
|
||||
id: int | None = None
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
# Additional properties to return via API
|
||||
class User(UserInDBBase):
|
||||
pass
|
||||
|
||||
|
||||
# Additional properties stored in DB
|
||||
class UserInDB(UserInDBBase):
|
||||
hashed_password: str
|
Reference in New Issue
Block a user