Skip to content

Commit 9e6e1f0

Browse files
committed
changes product config
1 parent c05de31 commit 9e6e1f0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

services/web/server/src/simcore_service_webserver/products/_models.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from models_library.basic_types import NonNegativeDecimal
1313
from models_library.emails import LowerCaseEmailStr
1414
from models_library.products import ProductName, StripePriceID, StripeTaxRateID
15-
from models_library.utils.change_case import snake_to_camel
1615
from pydantic import (
1716
BaseModel,
1817
BeforeValidator,
@@ -305,12 +304,11 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
305304
)
306305

307306
model_config = ConfigDict(
308-
alias_generator=snake_to_camel,
307+
# NOTE: do not add aliases. Use ProductGet schema for rest API
309308
from_attributes=True,
310309
frozen=True,
311310
json_schema_extra=_update_json_schema_extra,
312311
str_strip_whitespace=True,
313-
validate_by_alias=True,
314312
validate_by_name=True,
315313
extra="ignore",
316314
)
@@ -337,13 +335,12 @@ def to_statics(self) -> dict[str, Any]:
337335
},
338336
exclude_none=True,
339337
exclude_unset=True,
340-
by_alias=True,
341338
)
342339

343340
def get_template_name_for(self, filename: str) -> str | None:
344341
"""Checks for field marked with 'x_template_name' that fits the argument"""
345342
template_name = filename.removesuffix(".jinja2")
346-
for name, field in self.model_fields.items():
343+
for name, field in self.__class__.model_fields.items():
347344
if (
348345
field.json_schema_extra
349346
and field.json_schema_extra.get("x_template_name") == template_name # type: ignore[union-attr]

services/web/server/src/simcore_service_webserver/statics/_events.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from aiohttp.client import ClientSession
88
from aiohttp.client_exceptions import ClientConnectionError, ClientError
99
from common_library.json_serialization import json_dumps
10+
from models_library.utils.change_case import snake_to_camel
1011
from packaging.version import Version
1112
from servicelib.aiohttp.client_session import get_client_session
1213
from tenacity.asyncio import AsyncRetrying
@@ -122,7 +123,9 @@ async def create_and_cache_statics_json(app: web.Application) -> None:
122123
data = deepcopy(common)
123124

124125
_logger.debug("Product %s", product.name)
125-
data.update(product.to_statics())
126+
127+
product_data = {snake_to_camel(k): v for k, v in product.to_statics().items()}
128+
data.update(product_data)
126129

127130
# Adds specifics to login settings
128131
if (p := product.login_settings) and (v := p.get("LOGIN_2FA_REQUIRED", None)):

0 commit comments

Comments
 (0)