From 9cfce85fe918a8f3d84f09e44903823dcef44faf Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Thu, 10 Oct 2024 10:48:06 +0000 Subject: [PATCH] fix(specs): correct type for banners [skip-bc] (generated) https://github.com/algolia/api-clients-automation/pull/3939 Co-authored-by: algolia-bot --- .../recommend/models/banner_image.py | 6 +- algoliasearch/recommend/models/banners.py | 76 ------------------- algoliasearch/recommend/models/widgets.py | 9 ++- algoliasearch/search/models/banner_image.py | 6 +- algoliasearch/search/models/banners.py | 76 ------------------- algoliasearch/search/models/widgets.py | 9 ++- 6 files changed, 16 insertions(+), 166 deletions(-) delete mode 100644 algoliasearch/recommend/models/banners.py delete mode 100644 algoliasearch/search/models/banners.py diff --git a/algoliasearch/recommend/models/banner_image.py b/algoliasearch/recommend/models/banner_image.py index 2b960bd56..ab64f99c5 100644 --- a/algoliasearch/recommend/models/banner_image.py +++ b/algoliasearch/recommend/models/banner_image.py @@ -8,7 +8,7 @@ from json import loads from sys import version_info -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional from pydantic import BaseModel, ConfigDict @@ -35,7 +35,7 @@ class BannerImage(BaseModel): image of a search banner. """ - urls: Optional[BannerImageUrl] = None + urls: Optional[List[BannerImageUrl]] = None title: Optional[str] = None model_config = ConfigDict( @@ -72,7 +72,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) obj["urls"] = ( - BannerImageUrl.from_dict(obj["urls"]) + [BannerImageUrl.from_dict(_item) for _item in obj["urls"]] if obj.get("urls") is not None else None ) diff --git a/algoliasearch/recommend/models/banners.py b/algoliasearch/recommend/models/banners.py deleted file mode 100644 index 83ea01f02..000000000 --- a/algoliasearch/recommend/models/banners.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from sys import version_info -from typing import Any, Dict, Optional - -from pydantic import BaseModel, ConfigDict - -if version_info >= (3, 11): - from typing import Self -else: - from typing_extensions import Self - - -from algoliasearch.recommend.models.banner import Banner - -_ALIASES = { - "banners": "banners", -} - - -def _alias_generator(name: str) -> str: - return _ALIASES.get(name, name) - - -class Banners(BaseModel): - """ - banners defined in the merchandising studio for the given search. - """ - - banners: Optional[Banner] = None - - model_config = ConfigDict( - use_enum_values=True, - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - alias_generator=_alias_generator, - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Banners from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias.""" - return self.model_dump( - by_alias=True, - exclude_none=True, - exclude_unset=True, - ) - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Banners from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - obj["banners"] = ( - Banner.from_dict(obj["banners"]) if obj.get("banners") is not None else None - ) - - return cls.model_validate(obj) diff --git a/algoliasearch/recommend/models/widgets.py b/algoliasearch/recommend/models/widgets.py index df7fc687d..c469584bc 100644 --- a/algoliasearch/recommend/models/widgets.py +++ b/algoliasearch/recommend/models/widgets.py @@ -8,7 +8,7 @@ from json import loads from sys import version_info -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional from pydantic import BaseModel, ConfigDict @@ -18,7 +18,7 @@ from typing_extensions import Self -from algoliasearch.recommend.models.banners import Banners +from algoliasearch.recommend.models.banner import Banner _ALIASES = { "banners": "banners", @@ -34,7 +34,8 @@ class Widgets(BaseModel): widgets returned from any rules that are applied to the current search. """ - banners: Optional[Banners] = None + banners: Optional[List[Banner]] = None + """ banners defined in the merchandising studio for the given search. """ model_config = ConfigDict( use_enum_values=True, @@ -70,7 +71,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) obj["banners"] = ( - Banners.from_dict(obj["banners"]) + [Banner.from_dict(_item) for _item in obj["banners"]] if obj.get("banners") is not None else None ) diff --git a/algoliasearch/search/models/banner_image.py b/algoliasearch/search/models/banner_image.py index bcc62198b..84a0e7fc9 100644 --- a/algoliasearch/search/models/banner_image.py +++ b/algoliasearch/search/models/banner_image.py @@ -8,7 +8,7 @@ from json import loads from sys import version_info -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional from pydantic import BaseModel, ConfigDict @@ -35,7 +35,7 @@ class BannerImage(BaseModel): image of a search banner. """ - urls: Optional[BannerImageUrl] = None + urls: Optional[List[BannerImageUrl]] = None title: Optional[str] = None model_config = ConfigDict( @@ -72,7 +72,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) obj["urls"] = ( - BannerImageUrl.from_dict(obj["urls"]) + [BannerImageUrl.from_dict(_item) for _item in obj["urls"]] if obj.get("urls") is not None else None ) diff --git a/algoliasearch/search/models/banners.py b/algoliasearch/search/models/banners.py deleted file mode 100644 index fda833736..000000000 --- a/algoliasearch/search/models/banners.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding: utf-8 - -""" -Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -""" - -from __future__ import annotations - -from json import loads -from sys import version_info -from typing import Any, Dict, Optional - -from pydantic import BaseModel, ConfigDict - -if version_info >= (3, 11): - from typing import Self -else: - from typing_extensions import Self - - -from algoliasearch.search.models.banner import Banner - -_ALIASES = { - "banners": "banners", -} - - -def _alias_generator(name: str) -> str: - return _ALIASES.get(name, name) - - -class Banners(BaseModel): - """ - banners defined in the merchandising studio for the given search. - """ - - banners: Optional[Banner] = None - - model_config = ConfigDict( - use_enum_values=True, - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - alias_generator=_alias_generator, - ) - - def to_json(self) -> str: - return self.model_dump_json(by_alias=True, exclude_unset=True) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Banners from a JSON string""" - return cls.from_dict(loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias.""" - return self.model_dump( - by_alias=True, - exclude_none=True, - exclude_unset=True, - ) - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Banners from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - obj["banners"] = ( - Banner.from_dict(obj["banners"]) if obj.get("banners") is not None else None - ) - - return cls.model_validate(obj) diff --git a/algoliasearch/search/models/widgets.py b/algoliasearch/search/models/widgets.py index 5baaaf592..965989aa0 100644 --- a/algoliasearch/search/models/widgets.py +++ b/algoliasearch/search/models/widgets.py @@ -8,7 +8,7 @@ from json import loads from sys import version_info -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional from pydantic import BaseModel, ConfigDict @@ -18,7 +18,7 @@ from typing_extensions import Self -from algoliasearch.search.models.banners import Banners +from algoliasearch.search.models.banner import Banner _ALIASES = { "banners": "banners", @@ -34,7 +34,8 @@ class Widgets(BaseModel): widgets returned from any rules that are applied to the current search. """ - banners: Optional[Banners] = None + banners: Optional[List[Banner]] = None + """ banners defined in the merchandising studio for the given search. """ model_config = ConfigDict( use_enum_values=True, @@ -70,7 +71,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) obj["banners"] = ( - Banners.from_dict(obj["banners"]) + [Banner.from_dict(_item) for _item in obj["banners"]] if obj.get("banners") is not None else None )