Skip to content

Commit

Permalink
serialize version as an int
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBelthle committed Sep 25, 2024
1 parent 619946a commit d6b4c50
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion antarest/study/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pathlib import Path

from antares.study.version import StudyVersion
from pydantic import BaseModel, field_validator
from pydantic import BaseModel, field_validator, field_serializer
from sqlalchemy import ( # type: ignore
Boolean,
Column,
Expand Down Expand Up @@ -359,6 +359,10 @@ class StudyMetadataDTO(BaseModel):
folder: t.Optional[str] = None
tags: t.List[str] = []

@field_serializer('version', when_used='json')
def serialize_version(self, version: StudyVersion):
return version.__int__()

@field_validator("horizon", mode="before")
def transform_horizon_to_str(cls, val: t.Union[str, int, None]) -> t.Optional[str]:
# horizon can be an int.
Expand Down

0 comments on commit d6b4c50

Please sign in to comment.