11import logging
22from datetime import datetime
3- from typing import Any , NamedTuple
3+ from typing import Any , NamedTuple , cast
44
55from models_library .basic_types import IDStr
66from models_library .licensed_items import (
2222from models_library .users import UserID
2323from models_library .wallets import WalletID
2424from pydantic import BaseModel , ConfigDict , Field , PositiveInt
25+ from pydantic .config import JsonDict
2526from servicelib .request_keys import RQT_USERID_KEY
2627
2728from ..._constants import RQ_PRODUCT_KEY
@@ -37,21 +38,26 @@ class LicensedItem(BaseModel):
3738 pricing_plan_id : PricingPlanId
3839 created_at : datetime
3940 modified_at : datetime
40- model_config = ConfigDict (
41- json_schema_extra = {
42- "examples" : [
43- {
44- "licensed_item_id" : "0362b88b-91f8-4b41-867c-35544ad1f7a1" ,
45- "licensed_resource_name" : "best-model" ,
46- "licensed_resource_type" : f"{ LicensedResourceType .VIP_MODEL } " ,
47- "licensed_resource_data" : VIP_DETAILS_EXAMPLE ,
48- "pricing_plan_id" : "15" ,
49- "created_at" : "2024-12-12 09:59:26.422140" ,
50- "modified_at" : "2024-12-12 09:59:26.422140" ,
51- }
52- ]
53- }
54- )
41+
42+ @staticmethod
43+ def _update_json_schema_extra (schema : JsonDict ) -> None :
44+ schema .update (
45+ {
46+ "examples" : [
47+ {
48+ "licensed_item_id" : "0362b88b-91f8-4b41-867c-35544ad1f7a1" ,
49+ "licensed_resource_name" : "best-model" ,
50+ "licensed_resource_type" : f"{ LicensedResourceType .VIP_MODEL } " ,
51+ "licensed_resource_data" : cast (JsonDict , VIP_DETAILS_EXAMPLE ),
52+ "pricing_plan_id" : "15" ,
53+ "created_at" : "2024-12-12 09:59:26.422140" ,
54+ "modified_at" : "2024-12-12 09:59:26.422140" ,
55+ }
56+ ]
57+ }
58+ )
59+
60+ model_config = ConfigDict (json_schema_extra = _update_json_schema_extra )
5561
5662
5763class LicensedItemPage (NamedTuple ):
0 commit comments