-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(specs): make the searchParams compatible with v4 [skip-bc] (gener…
…ated) algolia/api-clients-automation#4108 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
- Loading branch information
1 parent
6112cd0
commit ae85461
Showing
14 changed files
with
574 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# 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 dumps, loads | ||
from sys import version_info | ||
from typing import Any, Dict, List, Optional, Set, Union | ||
|
||
from pydantic import BaseModel, Field, ValidationError, model_serializer | ||
|
||
if version_info >= (3, 11): | ||
from typing import Self | ||
else: | ||
from typing_extensions import Self | ||
|
||
|
||
class InsideBoundingBox(BaseModel): | ||
""" | ||
InsideBoundingBox | ||
""" | ||
|
||
oneof_schema_1_validator: Optional[str] = Field(default=None) | ||
|
||
oneof_schema_2_validator: Optional[List[List[float]]] = Field(default=None) | ||
""" Coordinates for a rectangular area in which to search. Each bounding box is defined by the two opposite points of its diagonal, and expressed as latitude and longitude pair: `[p1 lat, p1 long, p2 lat, p2 long]`. Provide multiple bounding boxes as nested arrays. For more information, see [rectangular area](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas). """ | ||
actual_instance: Union[List[List[float]], str, None] = None | ||
one_of_schemas: Set[str] = {"List[List[float]]", "str"} | ||
|
||
def __init__(self, *args, **kwargs) -> None: | ||
if args: | ||
if len(args) > 1: | ||
raise ValueError( | ||
"If a position argument is used, only 1 is allowed to set `actual_instance`" | ||
) | ||
if kwargs: | ||
raise ValueError( | ||
"If a position argument is used, keyword arguments cannot be used." | ||
) | ||
super().__init__(actual_instance=args[0]) # pyright: ignore | ||
else: | ||
super().__init__(**kwargs) | ||
|
||
@model_serializer | ||
def unwrap_actual_instance(self) -> Union[List[List[float]], str, Self, None]: | ||
""" | ||
Unwraps the `actual_instance` when calling the `to_json` method. | ||
""" | ||
return self.actual_instance if hasattr(self, "actual_instance") else self | ||
|
||
@classmethod | ||
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: | ||
"""Create an instance of InsideBoundingBox from a JSON string""" | ||
return cls.from_json(dumps(obj)) | ||
|
||
@classmethod | ||
def from_json(cls, json_str: Optional[str]) -> Self: | ||
"""Returns the object represented by the json string""" | ||
instance = cls.model_construct() | ||
if json_str is None: | ||
return instance | ||
|
||
error_messages = [] | ||
|
||
try: | ||
instance.oneof_schema_1_validator = loads(json_str) | ||
instance.actual_instance = instance.oneof_schema_1_validator | ||
|
||
return instance | ||
except (ValidationError, ValueError) as e: | ||
error_messages.append(str(e)) | ||
try: | ||
instance.oneof_schema_2_validator = loads(json_str) | ||
instance.actual_instance = instance.oneof_schema_2_validator | ||
|
||
return instance | ||
except (ValidationError, ValueError) as e: | ||
error_messages.append(str(e)) | ||
|
||
raise ValueError( | ||
"No match found when deserializing the JSON string into InsideBoundingBox with oneOf schemas: List[List[float]], str. Details: " | ||
+ ", ".join(error_messages) | ||
) | ||
|
||
def to_json(self) -> str: | ||
"""Returns the JSON representation of the actual instance""" | ||
if self.actual_instance is None: | ||
return "null" | ||
|
||
if hasattr(self.actual_instance, "to_json") and callable( | ||
self.actual_instance.to_json # pyright: ignore | ||
): | ||
return self.actual_instance.to_json() # pyright: ignore | ||
else: | ||
return dumps(self.actual_instance) | ||
|
||
def to_dict(self) -> Optional[Union[Dict[str, Any], List[List[float]], str]]: | ||
"""Returns the dict representation of the actual instance""" | ||
if self.actual_instance is None: | ||
return None | ||
|
||
if hasattr(self.actual_instance, "to_dict") and callable( | ||
self.actual_instance.to_dict # pyright: ignore | ||
): | ||
return self.actual_instance.to_dict() # pyright: ignore | ||
else: | ||
return self.actual_instance # pyright: ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# 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 dumps, loads | ||
from sys import version_info | ||
from typing import Any, Dict, List, Optional, Set, Union | ||
|
||
from pydantic import BaseModel, Field, ValidationError, model_serializer | ||
|
||
if version_info >= (3, 11): | ||
from typing import Self | ||
else: | ||
from typing_extensions import Self | ||
|
||
|
||
class OptionalWords(BaseModel): | ||
""" | ||
OptionalWords | ||
""" | ||
|
||
oneof_schema_1_validator: Optional[str] = Field(default=None) | ||
|
||
oneof_schema_2_validator: Optional[List[str]] = Field(default=None) | ||
""" Words that should be considered optional when found in the query. By default, records must match all words in the search query to be included in the search results. Adding optional words can help to increase the number of search results by running an additional search query that doesn't include the optional words. For example, if the search query is \"action video\" and \"video\" is an optional word, the search engine runs two queries. One for \"action video\" and one for \"action\". Records that match all words are ranked higher. For a search query with 4 or more words **and** all its words are optional, the number of matched words required for a record to be included in the search results increases for every 1,000 records: - If `optionalWords` has less than 10 words, the required number of matched words increases by 1: results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 2 matched words. - If `optionalWords` has 10 or more words, the number of required matched words increases by the number of optional words divided by 5 (rounded down). For example, with 18 optional words: results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 4 matched words. For more information, see [Optional words](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/empty-or-insufficient-results/#creating-a-list-of-optional-words). """ | ||
actual_instance: Union[List[str], str, None] = None | ||
one_of_schemas: Set[str] = {"List[str]", "str"} | ||
|
||
def __init__(self, *args, **kwargs) -> None: | ||
if args: | ||
if len(args) > 1: | ||
raise ValueError( | ||
"If a position argument is used, only 1 is allowed to set `actual_instance`" | ||
) | ||
if kwargs: | ||
raise ValueError( | ||
"If a position argument is used, keyword arguments cannot be used." | ||
) | ||
super().__init__(actual_instance=args[0]) # pyright: ignore | ||
else: | ||
super().__init__(**kwargs) | ||
|
||
@model_serializer | ||
def unwrap_actual_instance(self) -> Union[List[str], str, Self, None]: | ||
""" | ||
Unwraps the `actual_instance` when calling the `to_json` method. | ||
""" | ||
return self.actual_instance if hasattr(self, "actual_instance") else self | ||
|
||
@classmethod | ||
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: | ||
"""Create an instance of OptionalWords from a JSON string""" | ||
return cls.from_json(dumps(obj)) | ||
|
||
@classmethod | ||
def from_json(cls, json_str: Optional[str]) -> Self: | ||
"""Returns the object represented by the json string""" | ||
instance = cls.model_construct() | ||
if json_str is None: | ||
return instance | ||
|
||
error_messages = [] | ||
|
||
try: | ||
instance.oneof_schema_1_validator = loads(json_str) | ||
instance.actual_instance = instance.oneof_schema_1_validator | ||
|
||
return instance | ||
except (ValidationError, ValueError) as e: | ||
error_messages.append(str(e)) | ||
try: | ||
instance.oneof_schema_2_validator = loads(json_str) | ||
instance.actual_instance = instance.oneof_schema_2_validator | ||
|
||
return instance | ||
except (ValidationError, ValueError) as e: | ||
error_messages.append(str(e)) | ||
|
||
raise ValueError( | ||
"No match found when deserializing the JSON string into OptionalWords with oneOf schemas: List[str], str. Details: " | ||
+ ", ".join(error_messages) | ||
) | ||
|
||
def to_json(self) -> str: | ||
"""Returns the JSON representation of the actual instance""" | ||
if self.actual_instance is None: | ||
return "null" | ||
|
||
if hasattr(self.actual_instance, "to_json") and callable( | ||
self.actual_instance.to_json # pyright: ignore | ||
): | ||
return self.actual_instance.to_json() # pyright: ignore | ||
else: | ||
return dumps(self.actual_instance) | ||
|
||
def to_dict(self) -> Optional[Union[Dict[str, Any], List[str], str]]: | ||
"""Returns the dict representation of the actual instance""" | ||
if self.actual_instance is None: | ||
return None | ||
|
||
if hasattr(self.actual_instance, "to_dict") and callable( | ||
self.actual_instance.to_dict # pyright: ignore | ||
): | ||
return self.actual_instance.to_dict() # pyright: ignore | ||
else: | ||
return self.actual_instance # pyright: ignore |
Oops, something went wrong.