Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class _ItisVipRestData(OutputSchema):
description: str
thumbnail: str
features: FeaturesDict # NOTE: here there is a bit of coupling with domain model
doi: str
doi: str | None


class _ItisVipResourceRestData(OutputSchema):
Expand Down Expand Up @@ -92,13 +92,14 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
{
"categoryId": "HumanWholeBody",
"categoryDisplay": "Humans",
"source": VIP_DETAILS_EXAMPLE,
"source": {**VIP_DETAILS_EXAMPLE, "doi": doi},
},
),
"pricingPlanId": "15",
"createdAt": "2024-12-12 09:59:26.422140",
"modifiedAt": "2024-12-12 09:59:26.422140",
}
for doi in ["10.1000/xyz123", None]
]
}
)
Expand Down
9 changes: 8 additions & 1 deletion packages/models-library/src/models_library/licenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,14 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
"display_name": "my best model",
"licensed_resource_name": "best-model",
"licensed_resource_type": f"{LicensedResourceType.VIP_MODEL}",
"licensed_resource_data": cast(JsonDict, VIP_DETAILS_EXAMPLE),
"licensed_resource_data": cast(
JsonDict,
{
"category_id": "HumanWholeBody",
"category_display": "Humans",
"source": VIP_DETAILS_EXAMPLE,
},
),
"pricing_plan_id": "15",
"created_at": "2024-12-12 09:59:26.422140",
"modified_at": "2024-12-12 09:59:26.422140",
Expand Down
20 changes: 20 additions & 0 deletions packages/models-library/tests/test_licenses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from models_library.api_schemas_webserver.licensed_items import LicensedItemRestGet
from models_library.licenses import LicensedItem


def test_licensed_item_from_domain_model():
for example in LicensedItem.model_json_schema()["examples"]:
item = LicensedItem.model_validate(example)

payload = LicensedItemRestGet.from_domain_model(item)

assert item.display_name == payload.display_name

# nullable doi
assert (
payload.licensed_resource_data.source.doi
== item.licensed_resource_data["source"]["doi"]
)

# date is required
assert payload.licensed_resource_data.source.features["date"]
Original file line number Diff line number Diff line change
Expand Up @@ -15542,7 +15542,9 @@ components:
features:
$ref: '#/components/schemas/FeaturesDict'
doi:
type: string
anyOf:
- type: string
- type: 'null'
title: Doi
type: object
required:
Expand Down
Loading