29 lines
1016 B
Python
29 lines
1016 B
Python
from pydantic import BaseModel, Field
|
|
from typing import List
|
|
|
|
class DrugBase(BaseModel):
|
|
name: str = Field(..., description="Name of the drug")
|
|
description: str | None = Field(None, description="Description of the drug")
|
|
drug_types: List[str] | None = Field(None, description="Types of the drug")
|
|
|
|
class DrugCreate(DrugBase):
|
|
name: str = Field(..., description="Name of the drug")
|
|
description: str | None = Field(None, description="Description of the drug")
|
|
drug_types: List[str] | None = Field(None, description="Types of the drug")
|
|
|
|
class Config:
|
|
schema_extra = {
|
|
"example": {
|
|
"name": "Paracetamol",
|
|
"description": "Paracetamol is a commonly used over-the-counter medication to treat pain and fever.",
|
|
"drug_types": ["Analgesic", "Antipyretic"]
|
|
}
|
|
}
|
|
|
|
class DrugResponse(DrugBase):
|
|
name: str
|
|
description: str | None
|
|
drug_types: List[str] | None
|
|
|
|
class Config:
|
|
orm_mode = True |