Skip to content

Commit d110307

Browse files
algolia-botClaraMullerFluf22
committed
fix(specs): invalid API format for multi feed in Comp API (generated)
algolia/api-clients-automation#5993 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com> Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
1 parent 796e1ea commit d110307

File tree

3 files changed

+85
-3
lines changed

3 files changed

+85
-3
lines changed

algoliasearch/composition/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
from .facet_hits import FacetHits
5555
from .facet_ordering import FacetOrdering
5656
from .facet_stats import FacetStats
57+
from .feed_injection import FeedInjection
5758
from .get_task_response import GetTaskResponse
5859
from .highlight_result import HighlightResult
5960
from .highlight_result_option import HighlightResultOption
@@ -168,6 +169,7 @@
168169
"FacetHits",
169170
"FacetOrdering",
170171
"FacetStats",
172+
"FeedInjection",
171173
"GetTaskResponse",
172174
"HighlightResult",
173175
"HighlightResultOption",
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# coding: utf-8
2+
3+
"""
4+
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.
5+
"""
6+
7+
from __future__ import annotations
8+
9+
from json import loads
10+
from sys import version_info
11+
from typing import Any, Dict, Optional
12+
13+
from pydantic import BaseModel, ConfigDict
14+
15+
if version_info >= (3, 11):
16+
from typing import Self
17+
else:
18+
from typing_extensions import Self
19+
20+
21+
from algoliasearch.composition.models.injection import Injection
22+
23+
_ALIASES = {
24+
"injection": "injection",
25+
}
26+
27+
28+
def _alias_generator(name: str) -> str:
29+
return _ALIASES.get(name, name)
30+
31+
32+
class FeedInjection(BaseModel):
33+
"""
34+
Feed formatted as an injection.
35+
"""
36+
37+
injection: Injection
38+
39+
model_config = ConfigDict(
40+
strict=False,
41+
use_enum_values=True,
42+
populate_by_name=True,
43+
validate_assignment=True,
44+
protected_namespaces=(),
45+
alias_generator=_alias_generator,
46+
extra="allow",
47+
)
48+
49+
def to_json(self) -> str:
50+
return self.model_dump_json(by_alias=True, exclude_unset=True)
51+
52+
@classmethod
53+
def from_json(cls, json_str: str) -> Optional[Self]:
54+
"""Create an instance of FeedInjection from a JSON string"""
55+
return cls.from_dict(loads(json_str))
56+
57+
def to_dict(self) -> Dict[str, Any]:
58+
"""Return the dictionary representation of the model using alias."""
59+
return self.model_dump(
60+
by_alias=True,
61+
exclude_none=True,
62+
exclude_unset=True,
63+
)
64+
65+
@classmethod
66+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
67+
"""Create an instance of FeedInjection from a dict"""
68+
if obj is None:
69+
return None
70+
71+
if not isinstance(obj, dict):
72+
return cls.model_validate(obj)
73+
74+
obj["injection"] = (
75+
Injection.from_dict(obj["injection"])
76+
if obj.get("injection") is not None
77+
else None
78+
)
79+
80+
return cls.model_validate(obj)

algoliasearch/composition/models/multifeed.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from typing_extensions import Self
1919

2020

21-
from algoliasearch.composition.models.injection import Injection
21+
from algoliasearch.composition.models.feed_injection import FeedInjection
2222

2323
_ALIASES = {
2424
"feeds": "feeds",
@@ -35,7 +35,7 @@ class Multifeed(BaseModel):
3535
Multifeed
3636
"""
3737

38-
feeds: Dict[str, Injection]
38+
feeds: Dict[str, FeedInjection]
3939
""" A key-value store of Feed ID to Feed. Currently, the only supported Feed type is an Injection. """
4040
feeds_order: Optional[List[str]] = None
4141
""" A list of Feed IDs that specifies the order in which to order the results in the response. The IDs should be a subset of those in the Feeds object, and only those specified will be processed. When this field is not set, all Feeds are processed and returned with a default ordering. """
@@ -76,7 +76,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
7676
return cls.model_validate(obj)
7777

7878
obj["feeds"] = (
79-
dict((_k, Injection.from_dict(_v)) for _k, _v in obj["feeds"].items())
79+
dict((_k, FeedInjection.from_dict(_v)) for _k, _v in obj["feeds"].items())
8080
if obj.get("feeds") is not None
8181
else None
8282
)

0 commit comments

Comments
 (0)