diff --git a/src/cpr_sdk/pipeline_general_models.py b/src/cpr_sdk/pipeline_general_models.py index 195745f..7096e68 100644 --- a/src/cpr_sdk/pipeline_general_models.py +++ b/src/cpr_sdk/pipeline_general_models.py @@ -2,7 +2,7 @@ from enum import Enum from typing import Mapping, Any, List, Optional, Sequence, Union -from pydantic import BaseModel, model_validator +from pydantic import BaseModel, field_validator, model_validator Json = dict[str, Any] @@ -54,6 +54,21 @@ def convert_publication_ts_to_date(self): return self + @field_validator("type", mode="before") + @classmethod + def none_to_empty_string(cls, value): + """If the value is None, will convert to an empty string""" + return "" if value is None else value + + def to_json(self) -> Mapping[str, Any]: + """Provide a serialisable version of the model""" + + json_dict = self.model_dump() + json_dict["publication_ts"] = ( + self.publication_ts.isoformat() if self.publication_ts is not None else None + ) + return json_dict + class InputData(BaseModel): """Expected input data containing RDS state.""" diff --git a/src/cpr_sdk/version.py b/src/cpr_sdk/version.py index 850f722..19cdcb8 100644 --- a/src/cpr_sdk/version.py +++ b/src/cpr_sdk/version.py @@ -1,5 +1,5 @@ _MAJOR = "1" -_MINOR = "1" +_MINOR = "2" _PATCH = "10" _SUFFIX = ""