mirror of
https://github.com/rjNemo/fastapi
synced 2026-06-06 18:46:40 +00:00
37 lines
496 B
Python
37 lines
496 B
Python
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class ItemBase(BaseModel):
|
|
title: str
|
|
description: Optional[str] = None
|
|
|
|
|
|
class ItemCreate(ItemBase):
|
|
pass
|
|
|
|
|
|
class Item(ItemBase):
|
|
id: int
|
|
owner_id: int
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class UserBase(BaseModel):
|
|
email: str
|
|
|
|
|
|
class UserCreate(UserBase):
|
|
password: str
|
|
|
|
|
|
class User(UserBase):
|
|
id: int
|
|
is_active: bool
|
|
items: list[Item] = []
|
|
|
|
class Config:
|
|
orm_mode = True
|