Add User schema
This commit is contained in:
parent
b0ba7cfbc0
commit
ca69ff0674
25
schemas/user.py
Normal file
25
schemas/user.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
from pydantic import BaseModel, Field
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
class UserBase(BaseModel):
|
||||||
|
name: Optional[str] = Field(None, min_length=1, max_length=100, description="User's name")
|
||||||
|
|
||||||
|
class UserCreate(UserBase):
|
||||||
|
class Config:
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"name": "John Doe"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class User(UserBase):
|
||||||
|
id: int
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
orm_mode = True
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"id": 1,
|
||||||
|
"name": "John Doe"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user