25 lines
560 B
Python
25 lines
560 B
Python
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"
|
|
}
|
|
} |