Skip to content

Commit 90cc5ef

Browse files
committed
cleanup
1 parent dd342a3 commit 90cc5ef

File tree

3 files changed

+27
-23
lines changed
  • api/specs/web-server
  • packages/models-library/src/models_library/api_schemas_webserver
  • services/web/server/src/simcore_service_webserver/products

3 files changed

+27
-23
lines changed

api/specs/web-server/_products.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from models_library.api_schemas_webserver.product import (
1212
GenerateInvitation,
1313
GetCreditPrice,
14-
GetProduct,
1514
InvitationGenerated,
15+
ProductGet,
1616
UpdateProductTemplate,
1717
)
1818
from models_library.generics import Envelope
@@ -40,7 +40,8 @@ async def get_current_product_price():
4040

4141
@router.get(
4242
"/products/{product_name}",
43-
response_model=Envelope[GetProduct],
43+
response_model=Envelope[ProductGet],
44+
description="NOTE: `/products/current` is used to define current project w/o naming it",
4445
tags=[
4546
"po",
4647
],

packages/models-library/src/models_library/api_schemas_webserver/product.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,31 +60,34 @@ class UpdateProductTemplate(InputSchema):
6060
content: str
6161

6262

63-
class GetProduct(OutputSchema):
63+
class ProductGet(OutputSchema):
6464
name: ProductName
6565
display_name: str
66-
short_name: str | None = Field(
67-
default=None, description="Short display name for SMS"
68-
)
69-
70-
vendor: dict | None = Field(default=None, description="vendor attributes")
71-
issues: list[dict] | None = Field(
72-
default=None, description="Reference to issues tracker"
73-
)
74-
manuals: list[dict] | None = Field(default=None, description="List of manuals")
75-
support: list[dict] | None = Field(
76-
default=None, description="List of support resources"
77-
)
66+
short_name: Annotated[
67+
str | None, Field(description="Short display name for SMS")
68+
] = None
69+
70+
vendor: Annotated[dict | None, Field(description="vendor attributes")] = None
71+
issues: Annotated[
72+
list[dict] | None, Field(description="Reference to issues tracker")
73+
] = None
74+
manuals: Annotated[list[dict] | None, Field(description="List of manuals")] = None
75+
support: Annotated[
76+
list[dict] | None, Field(description="List of support resources")
77+
] = None
7878

7979
login_settings: dict
8080
max_open_studies_per_user: PositiveInt | None
8181
is_payment_enabled: bool
8282
credits_per_usd: NonNegativeDecimal | None
8383

84-
templates: list[GetProductTemplate] = Field(
85-
default_factory=list,
86-
description="List of templates available to this product for communications (e.g. emails, sms, etc)",
87-
)
84+
templates: Annotated[
85+
list[GetProductTemplate],
86+
Field(
87+
description="List of templates available to this product for communications (e.g. emails, sms, etc)",
88+
default_factory=list,
89+
),
90+
]
8891

8992

9093
ExtraCreditsUsdRangeInt: TypeAlias = Annotated[int, Field(ge=0, lt=500)]

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Literal
33

44
from aiohttp import web
5-
from models_library.api_schemas_webserver.product import GetCreditPrice, GetProduct
5+
from models_library.api_schemas_webserver.product import GetCreditPrice, ProductGet
66
from models_library.basic_types import IDStr
77
from models_library.rest_base import RequestParameters, StrictRequestParameters
88
from models_library.users import UserID
@@ -69,9 +69,9 @@ async def _get_product(request: web.Request):
6969
except KeyError as err:
7070
raise web.HTTPNotFound(reason=f"{product_name=} not found") from err
7171

72-
assert "extra" in GetProduct.model_config # nosec
73-
assert GetProduct.model_config["extra"] == "ignore" # nosec
74-
data = GetProduct(**product.model_dump(), templates=[])
72+
assert "extra" in ProductGet.model_config # nosec
73+
assert ProductGet.model_config["extra"] == "ignore" # nosec
74+
data = ProductGet(**product.model_dump(), templates=[])
7575
return envelope_json_response(data)
7676

7777

0 commit comments

Comments
 (0)