Skip to content

Commit

Permalink
🐛 Fix Decimal serialization (#6854)
Browse files Browse the repository at this point in the history
  • Loading branch information
giancarloromeo authored Dec 4, 2024
1 parent 81e5b8e commit dc28926
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from datetime import datetime
from decimal import Decimal
from typing import Annotated

from pydantic import BaseModel, ConfigDict, PlainSerializer
from pydantic import BaseModel, ConfigDict

from ..resource_tracker import (
HardwareInfo,
Expand All @@ -19,9 +18,7 @@ class PricingUnitGet(BaseModel):
pricing_unit_id: PricingUnitId
unit_name: str
unit_extra_info: UnitExtraInfo
current_cost_per_unit: Annotated[
Decimal, PlainSerializer(float, return_type=float, when_used="json")
]
current_cost_per_unit: Decimal
current_cost_per_unit_id: PricingUnitCostId
default: bool
specific_info: HardwareInfo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from datetime import datetime
from decimal import Decimal
from typing import Annotated

from pydantic import BaseModel, ConfigDict, Field, PlainSerializer
from pydantic import BaseModel, ConfigDict, Field

from ..projects import ProjectID
from ..projects_nodes_io import NodeID
Expand Down Expand Up @@ -50,9 +49,7 @@ class PricingUnitGet(OutputSchema):
pricing_unit_id: PricingUnitId
unit_name: str
unit_extra_info: UnitExtraInfo
current_cost_per_unit: Annotated[
Decimal, PlainSerializer(float, return_type=float, when_used="json")
]
current_cost_per_unit: Decimal
default: bool


Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
from datetime import datetime
from decimal import Decimal
from typing import Annotated, Literal, TypeAlias
from typing import Literal, TypeAlias

from pydantic import (
ConfigDict,
Field,
HttpUrl,
PlainSerializer,
ValidationInfo,
field_validator,
)
from pydantic import ConfigDict, Field, HttpUrl, ValidationInfo, field_validator

from ..basic_types import AmountDecimal, IDStr, NonNegativeDecimal
from ..users import GroupID
Expand All @@ -20,9 +13,9 @@
class WalletGet(OutputSchema):
wallet_id: WalletID
name: IDStr
description: str | None
description: str | None = None
owner: GroupID
thumbnail: str | None
thumbnail: str | None = None
status: WalletStatus
created: datetime
modified: datetime
Expand All @@ -31,7 +24,7 @@ class WalletGet(OutputSchema):


class WalletGetWithAvailableCredits(WalletGet):
available_credits: Annotated[Decimal, PlainSerializer(float)]
available_credits: Decimal


class WalletGetPermissions(WalletGet):
Expand Down
4 changes: 2 additions & 2 deletions services/api-server/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -6492,7 +6492,7 @@
"$ref": "#/components/schemas/UnitExtraInfo"
},
"currentCostPerUnit": {
"type": "number",
"type": "string",
"title": "Currentcostperunit"
},
"default": {
Expand Down Expand Up @@ -7093,7 +7093,7 @@
"title": "Modified"
},
"availableCredits": {
"type": "number",
"type": "string",
"title": "Availablecredits"
}
},
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion services/web/server/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.46.0
0.47.0
2 changes: 1 addition & 1 deletion services/web/server/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.46.0
current_version = 0.47.0
commit = True
message = services/webserver api version: {current_version} → {new_version}
tag = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.1.0
info:
title: simcore-service-webserver
description: Main service with an interface (http-API & websockets) to the web front-end
version: 0.46.0
version: 0.47.0
servers:
- url: ''
description: webserver
Expand Down Expand Up @@ -11314,7 +11314,7 @@ components:
unitExtraInfo:
$ref: '#/components/schemas/UnitExtraInfo-Output'
currentCostPerUnit:
type: number
type: string
title: Currentcostperunit
default:
type: boolean
Expand Down Expand Up @@ -11358,7 +11358,7 @@ components:
unitExtraInfo:
$ref: '#/components/schemas/UnitExtraInfo-Output'
currentCostPerUnit:
type: number
type: string
title: Currentcostperunit
default:
type: boolean
Expand Down Expand Up @@ -14079,7 +14079,7 @@ components:
format: date-time
title: Modified
availableCredits:
type: number
type: string
title: Availablecredits
type: object
required:
Expand Down

0 comments on commit dc28926

Please sign in to comment.