Add Drug schema
This commit is contained in:
parent
3c062e51fd
commit
d50138a9ff
29
schemas/drug.py
Normal file
29
schemas/drug.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
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
|
Loading…
x
Reference in New Issue
Block a user