Add Generic schema
This commit is contained in:
parent
64347e88e1
commit
aefe47217e
37
schemas/generic.py
Normal file
37
schemas/generic.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
from pydantic import BaseModel, Field
|
||||||
|
from typing import Optional
|
||||||
|
from datetime import datetime
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
class GenericBase(BaseModel):
|
||||||
|
name: str = Field(..., description="Generic item name", index=True)
|
||||||
|
description: Optional[str] = Field(None, description="Generic item description")
|
||||||
|
status: str = Field(default="active", description="Generic item status")
|
||||||
|
|
||||||
|
class GenericCreate(GenericBase):
|
||||||
|
class Config:
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"name": "Sample Generic Item",
|
||||||
|
"description": "This is a sample generic item description",
|
||||||
|
"status": "active"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Generic(GenericBase):
|
||||||
|
id: UUID
|
||||||
|
created_at: datetime
|
||||||
|
updated_at: datetime
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
orm_mode = True
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"id": "550e8400-e29b-41d4-a716-446655440000",
|
||||||
|
"name": "Sample Generic Item",
|
||||||
|
"description": "This is a sample generic item description",
|
||||||
|
"status": "active",
|
||||||
|
"created_at": "2023-01-01T00:00:00",
|
||||||
|
"updated_at": "2023-01-01T00:00:00"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user