25 lines
675 B
Python
25 lines
675 B
Python
from typing import Optional
|
|
from bson import ObjectId
|
|
from pydantic import BaseModel, Field
|
|
from app.models.entities import PyObjectId
|
|
|
|
|
|
class SubjectEntity(BaseModel):
|
|
id: Optional[PyObjectId] = Field(default=None, alias="_id")
|
|
name: str
|
|
short_name: str
|
|
description: Optional[str] = None
|
|
icon: Optional[str] = None
|
|
|
|
class Config:
|
|
populate_by_name = True
|
|
json_encoders = {ObjectId: str}
|
|
json_schema_extra = {
|
|
"example": {
|
|
"_id": "sejarah",
|
|
"name": "Sejarah",
|
|
"description": "Kuis tentang sejarah Indonesia",
|
|
"icon": "http://",
|
|
}
|
|
}
|