From f7c82c29f221feeea569e027b8da45e0d325103b Mon Sep 17 00:00:00 2001 From: Mads Bisgaard Date: Thu, 5 Dec 2024 15:11:54 +0100 Subject: [PATCH] allow to populate cover models by name --- .../models/schemas/model_adapter.py | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/services/api-server/src/simcore_service_api_server/models/schemas/model_adapter.py b/services/api-server/src/simcore_service_api_server/models/schemas/model_adapter.py index d769d90e041..9cc8b768d45 100644 --- a/services/api-server/src/simcore_service_api_server/models/schemas/model_adapter.py +++ b/services/api-server/src/simcore_service_api_server/models/schemas/model_adapter.py @@ -25,10 +25,20 @@ ) from models_library.users import GroupID from models_library.wallets import WalletID, WalletStatus -from pydantic import BaseModel, Field, NonNegativeFloat, NonNegativeInt, PlainSerializer +from pydantic import ( + BaseModel, + ConfigDict, + Field, + NonNegativeFloat, + NonNegativeInt, + PlainSerializer, +) class GetCreditPriceLegacy(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) product_name: str = Field(alias="productName") usd_per_credit: ( Annotated[ @@ -56,6 +66,9 @@ class GetCreditPriceLegacy(BaseModel): class PricingUnitGetLegacy(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) pricing_unit_id: PricingUnitId = Field(alias="pricingUnitId") unit_name: str = Field(alias="unitName") unit_extra_info: UnitExtraInfo = Field(alias="unitExtraInfo") @@ -71,6 +84,9 @@ class PricingUnitGetLegacy(BaseModel): class WalletGetWithAvailableCreditsLegacy(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) wallet_id: WalletID = Field(alias="walletId") name: IDStr description: str | None = None @@ -90,6 +106,9 @@ class WalletGetWithAvailableCreditsLegacy(BaseModel): class ServicePricingPlanGetLegacy(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) pricing_plan_id: PricingPlanId = Field(alias="pricingPlanId") display_name: str = Field(alias="displayName") description: str