Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Commit

Permalink
fix(config-schema): not using base abstract class
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinNitroG committed Jan 10, 2025
1 parent 4b442a6 commit 39e369d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 16 deletions.
59 changes: 46 additions & 13 deletions schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@
"title": "ApiEnum",
"type": "string"
},
"BaseNotificationConfig": {
"properties": {
"enabled": {
"default": true,
"description": "Kích hoạt",
"title": "Enabled",
"type": "boolean"
}
},
"title": "Lớp cơ sở notification bao gồm trường enabled cho các lớp kế thừa",
"type": "object"
},
"PlateInfo": {
"properties": {
"plate": {
Expand Down Expand Up @@ -99,6 +87,51 @@
"title": "Thông tin thiết lập cho biển số",
"type": "object"
},
"TelegramNotificationConfig": {
"properties": {
"enabled": {
"default": true,
"description": "Kích hoạt",
"title": "Enabled",
"type": "boolean"
},
"telegram": {
"$ref": "#/$defs/TelegramNotificationEngineConfig",
"description": "Telegram"
}
},
"required": [
"telegram"
],
"title": "Telegram và kích hoạt",
"type": "object"
},
"TelegramNotificationEngineConfig": {
"properties": {
"bot_token": {
"description": "Bot token Telegram",
"examples": [
"2780473231:weiruAShGUUx4oLOMoUhd0GiREXSZcCq-uB"
],
"title": "Bot Token",
"type": "string"
},
"chat_id": {
"description": "Chat ID Telegram",
"examples": [
"-1001790012349"
],
"title": "Chat Id",
"type": "string"
}
},
"required": [
"bot_token",
"chat_id"
],
"title": "Telegram",
"type": "object"
},
"VehicleTypeEnum": {
"enum": [
1,
Expand All @@ -122,7 +155,7 @@
"notifications": {
"description": "Danh sách các thiết lập để thông báo",
"items": {
"$ref": "#/$defs/BaseNotificationConfig"
"$ref": "#/$defs/TelegramNotificationConfig"
},
"title": "Danh sách thông báo",
"type": "array"
Expand Down
7 changes: 4 additions & 3 deletions src/check_phat_nguoi/config/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from check_phat_nguoi.types import ApiEnum, LogLevelType

from .notifications.base_notification import (
BaseNotificationConfig,
from .notifications.telegram_notification import (
TelegramNotificationConfig,
)
from .plate_info import PlateInfo

Expand All @@ -22,7 +22,8 @@ class Config(BaseModel):
description="Danh sách các biển xe",
min_length=1,
)
notifications: tuple[BaseNotificationConfig, ...] = Field(
# NOTE: Do not put base class in here. Because it will be wrong in schema.
notifications: tuple[TelegramNotificationConfig, ...] = Field(
title="Danh sách thông báo",
description="Danh sách các thiết lập để thông báo",
default_factory=tuple,
Expand Down

0 comments on commit 39e369d

Please sign in to comment.