Skip to content

Commit 50b017d

Browse files
authored
šŸ› fixes failure due to nullable doi in licensed-items web-api response (#7177)
1 parent 4653f36 commit 50b017d

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

ā€Žpackages/models-library/src/models_library/api_schemas_webserver/licensed_items.pyā€Ž

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class _ItisVipRestData(OutputSchema):
5656
description: str
5757
thumbnail: str
5858
features: FeaturesDict # NOTE: here there is a bit of coupling with domain model
59-
doi: str
59+
doi: str | None
6060

6161

6262
class _ItisVipResourceRestData(OutputSchema):
@@ -92,13 +92,14 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
9292
{
9393
"categoryId": "HumanWholeBody",
9494
"categoryDisplay": "Humans",
95-
"source": VIP_DETAILS_EXAMPLE,
95+
"source": {**VIP_DETAILS_EXAMPLE, "doi": doi},
9696
},
9797
),
9898
"pricingPlanId": "15",
9999
"createdAt": "2024-12-12 09:59:26.422140",
100100
"modifiedAt": "2024-12-12 09:59:26.422140",
101101
}
102+
for doi in ["10.1000/xyz123", None]
102103
]
103104
}
104105
)

ā€Žpackages/models-library/src/models_library/licenses.pyā€Ž

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,14 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
110110
"display_name": "my best model",
111111
"licensed_resource_name": "best-model",
112112
"licensed_resource_type": f"{LicensedResourceType.VIP_MODEL}",
113-
"licensed_resource_data": cast(JsonDict, VIP_DETAILS_EXAMPLE),
113+
"licensed_resource_data": cast(
114+
JsonDict,
115+
{
116+
"category_id": "HumanWholeBody",
117+
"category_display": "Humans",
118+
"source": VIP_DETAILS_EXAMPLE,
119+
},
120+
),
114121
"pricing_plan_id": "15",
115122
"created_at": "2024-12-12 09:59:26.422140",
116123
"modified_at": "2024-12-12 09:59:26.422140",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from models_library.api_schemas_webserver.licensed_items import LicensedItemRestGet
2+
from models_library.licenses import LicensedItem
3+
4+
5+
def test_licensed_item_from_domain_model():
6+
for example in LicensedItem.model_json_schema()["examples"]:
7+
item = LicensedItem.model_validate(example)
8+
9+
payload = LicensedItemRestGet.from_domain_model(item)
10+
11+
assert item.display_name == payload.display_name
12+
13+
# nullable doi
14+
assert (
15+
payload.licensed_resource_data.source.doi
16+
== item.licensed_resource_data["source"]["doi"]
17+
)
18+
19+
# date is required
20+
assert payload.licensed_resource_data.source.features["date"]

ā€Žservices/web/server/src/simcore_service_webserver/api/v0/openapi.yamlā€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15542,7 +15542,9 @@ components:
1554215542
features:
1554315543
$ref: '#/components/schemas/FeaturesDict'
1554415544
doi:
15545-
type: string
15545+
anyOf:
15546+
- type: string
15547+
- type: 'null'
1554615548
title: Doi
1554715549
type: object
1554815550
required:

0 commit comments

Comments
Ā (0)