Skip to content

Commit 70f0941

Browse files
committed
feat: enhance id property with JSON schema annotations in multiple models
1 parent 254139c commit 70f0941

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

deadlock_assets_api/models/v2/build_tag.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
from typing import Annotated
2+
13
from murmurhash2 import murmurhash2
2-
from pydantic import BaseModel, ConfigDict, computed_field
4+
from pydantic import BaseModel, ConfigDict, computed_field, WithJsonSchema
35

46
from deadlock_assets_api.glob import SVGS_BASE_URL
57

@@ -12,7 +14,7 @@ class BuildTagV2(BaseModel):
1214

1315
@computed_field
1416
@property
15-
def id(self) -> int:
17+
def id(self) -> Annotated[int, WithJsonSchema({"format": "int64", "type": "integer"})]:
1618
return murmurhash2(self.class_name.encode(), 0x31415926)
1719

1820
@computed_field

deadlock_assets_api/models/v2/misc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import logging
2+
from typing import Annotated
23

34
from murmurhash2 import murmurhash2
4-
from pydantic import ConfigDict, Field, BaseModel, computed_field
5+
from pydantic import ConfigDict, Field, BaseModel, computed_field, WithJsonSchema
56

67
LOGGER = logging.getLogger(__name__)
78

@@ -131,5 +132,5 @@ class MiscV2(BaseModel):
131132

132133
@computed_field
133134
@property
134-
def id(self) -> int:
135+
def id(self) -> Annotated[int, WithJsonSchema({"format": "int64", "type": "integer"})]:
135136
return murmurhash2(self.class_name.encode(), 0x31415926)

deadlock_assets_api/models/v2/npc_unit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import logging
2+
from typing import Annotated
23

34
from murmurhash2 import murmurhash2
4-
from pydantic import ConfigDict, Field, BaseModel, computed_field
5+
from pydantic import ConfigDict, Field, BaseModel, computed_field, WithJsonSchema
56

67
from deadlock_assets_api.models.v2.raw_weapon import RawWeaponInfoV2
78

@@ -92,5 +93,5 @@ class NPCUnitV2(BaseModel):
9293

9394
@computed_field
9495
@property
95-
def id(self) -> int:
96+
def id(self) -> Annotated[int, WithJsonSchema({"format": "int64", "type": "integer"})]:
9697
return murmurhash2(self.class_name.encode(), 0x31415926)

0 commit comments

Comments
 (0)