We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c2c98d3 commit a68cdc4Copy full SHA for a68cdc4
packages/models-library/src/models_library/api_schemas_resource_usage_tracker/credit_transactions.py
@@ -1,7 +1,7 @@
1
from datetime import datetime
2
from decimal import Decimal
3
4
-from pydantic import BaseModel, field_validator
+from pydantic import BaseModel, ConfigDict, field_validator
5
6
from ..products import ProductName
7
from ..resource_tracker import CreditTransactionId
@@ -13,7 +13,9 @@ class WalletTotalCredits(BaseModel):
13
wallet_id: WalletID
14
available_osparc_credits: Decimal
15
16
- @field_validator("available_osparc_credits")
+ model_config = ConfigDict(json_encoders={Decimal: float})
17
+
18
+ @field_validator("available_osparc_credits", mode="before")
19
@classmethod
20
def ensure_rounded(cls, v):
21
return round(v, 2)
0 commit comments