File tree Expand file tree Collapse file tree 4 files changed +34
-4
lines changed
services/web/server/src/simcore_service_webserver/api/v0 Expand file tree Collapse file tree 4 files changed +34
-4
lines changed Original file line number Diff line number Diff 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
6262class _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 )
Original file line number Diff line number Diff 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" ,
Original file line number Diff line number Diff line change 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" ]
Original file line number Diff line number Diff 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 :
You canāt perform that action at this time.
0 commit comments