Skip to content

Commit 6a7c3df

Browse files
stackit-pipelineFyusel
authored andcommitted
Generate serviceenablement
1 parent 7733b68 commit 6a7c3df

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

services/serviceenablement/src/stackit/serviceenablement/models/error_response.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515

1616
import json
1717
import pprint
18+
import re # noqa: F401
1819
from datetime import datetime
1920
from typing import Any, ClassVar, Dict, List, Optional, Set
2021

21-
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
22+
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator
2223
from typing_extensions import Self
2324

2425

@@ -34,6 +35,19 @@ class ErrorResponse(BaseModel):
3435
timestamp: Optional[datetime] = None
3536
__properties: ClassVar[List[str]] = ["error", "message", "path", "status", "timestamp"]
3637

38+
@field_validator("timestamp", mode="before")
39+
def timestamp_change_year_zero_to_one(cls, value):
40+
"""Workaround which prevents year 0 issue"""
41+
if isinstance(value, str):
42+
# Check for year "0000" at the beginning of the string
43+
# This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ
44+
if value.startswith("0000-01-01T") and re.match(
45+
r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value
46+
):
47+
# Workaround: Replace "0000" with "0001"
48+
return "0001" + value[4:] # Take "0001" and append the rest of the string
49+
return value
50+
3751
model_config = ConfigDict(
3852
populate_by_name=True,
3953
validate_assignment=True,

0 commit comments

Comments
 (0)