Skip to content

Commit df6c63b

Browse files
algolia-botmillotp
andcommitted
fix(specs): ignorePlurals can be a boolean string (generated)
algolia/api-clients-automation#3620 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 7e7764e commit df6c63b

File tree

4 files changed

+102
-12
lines changed

4 files changed

+102
-12
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 enum import Enum
10+
from json import loads
11+
from sys import version_info
12+
13+
if version_info >= (3, 11):
14+
from typing import Self
15+
else:
16+
from typing_extensions import Self
17+
18+
19+
class BooleanString(str, Enum):
20+
"""
21+
BooleanString
22+
"""
23+
24+
"""
25+
allowed enum values
26+
"""
27+
TRUE = "true"
28+
FALSE = "false"
29+
30+
@classmethod
31+
def from_json(cls, json_str: str) -> Self:
32+
"""Create an instance of BooleanString from a JSON string"""
33+
return cls(loads(json_str))

algoliasearch/recommend/models/ignore_plurals.py

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

2020

21+
from algoliasearch.recommend.models.boolean_string import BooleanString
2122
from algoliasearch.recommend.models.supported_language import SupportedLanguage
2223

2324

@@ -30,11 +31,14 @@ class IgnorePlurals(BaseModel):
3031
default=None,
3132
description="ISO code for languages for which this feature should be active. This overrides languages you set with `queryLanguages`. ",
3233
)
33-
oneof_schema_2_validator: Optional[StrictBool] = Field(
34+
oneof_schema_2_validator: Optional[BooleanString] = None
35+
oneof_schema_3_validator: Optional[StrictBool] = Field(
3436
default=False,
3537
description="If true, `ignorePlurals` is active for all languages included in `queryLanguages`, or for all supported languages, if `queryLanguges` is empty. If false, singulars, plurals, and other declensions won't be considered equivalent. ",
3638
)
37-
actual_instance: Optional[Union[List[SupportedLanguage], bool]] = None
39+
actual_instance: Optional[Union[BooleanString, List[SupportedLanguage], bool]] = (
40+
None
41+
)
3842

3943
def __init__(self, *args, **kwargs) -> None:
4044
if args:
@@ -51,7 +55,9 @@ def __init__(self, *args, **kwargs) -> None:
5155
super().__init__(**kwargs)
5256

5357
@model_serializer
54-
def unwrap_actual_instance(self) -> Optional[Union[List[SupportedLanguage], bool]]:
58+
def unwrap_actual_instance(
59+
self,
60+
) -> Optional[Union[BooleanString, List[SupportedLanguage], bool]]:
5561
"""
5662
Unwraps the `actual_instance` when calling the `to_json` method.
5763
"""
@@ -75,15 +81,21 @@ def from_json(cls, json_str: str) -> Self:
7581
except (ValidationError, ValueError) as e:
7682
error_messages.append(str(e))
7783
try:
78-
instance.oneof_schema_2_validator = loads(json_str)
79-
instance.actual_instance = instance.oneof_schema_2_validator
84+
instance.actual_instance = BooleanString.from_json(json_str)
85+
86+
return instance
87+
except (ValidationError, ValueError) as e:
88+
error_messages.append(str(e))
89+
try:
90+
instance.oneof_schema_3_validator = loads(json_str)
91+
instance.actual_instance = instance.oneof_schema_3_validator
8092

8193
return instance
8294
except (ValidationError, ValueError) as e:
8395
error_messages.append(str(e))
8496

8597
raise ValueError(
86-
"No match found when deserializing the JSON string into IgnorePlurals with oneOf schemas: List[SupportedLanguage], bool. Details: "
98+
"No match found when deserializing the JSON string into IgnorePlurals with oneOf schemas: BooleanString, List[SupportedLanguage], bool. Details: "
8799
+ ", ".join(error_messages)
88100
)
89101

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 enum import Enum
10+
from json import loads
11+
from sys import version_info
12+
13+
if version_info >= (3, 11):
14+
from typing import Self
15+
else:
16+
from typing_extensions import Self
17+
18+
19+
class BooleanString(str, Enum):
20+
"""
21+
BooleanString
22+
"""
23+
24+
"""
25+
allowed enum values
26+
"""
27+
TRUE = "true"
28+
FALSE = "false"
29+
30+
@classmethod
31+
def from_json(cls, json_str: str) -> Self:
32+
"""Create an instance of BooleanString from a JSON string"""
33+
return cls(loads(json_str))

algoliasearch/search/models/ignore_plurals.py

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

2020

21+
from algoliasearch.search.models.boolean_string import BooleanString
2122
from algoliasearch.search.models.supported_language import SupportedLanguage
2223

2324

@@ -30,11 +31,14 @@ class IgnorePlurals(BaseModel):
3031
default=None,
3132
description="ISO code for languages for which this feature should be active. This overrides languages you set with `queryLanguages`. ",
3233
)
33-
oneof_schema_2_validator: Optional[StrictBool] = Field(
34+
oneof_schema_2_validator: Optional[BooleanString] = None
35+
oneof_schema_3_validator: Optional[StrictBool] = Field(
3436
default=False,
3537
description="If true, `ignorePlurals` is active for all languages included in `queryLanguages`, or for all supported languages, if `queryLanguges` is empty. If false, singulars, plurals, and other declensions won't be considered equivalent. ",
3638
)
37-
actual_instance: Optional[Union[List[SupportedLanguage], bool]] = None
39+
actual_instance: Optional[Union[BooleanString, List[SupportedLanguage], bool]] = (
40+
None
41+
)
3842

3943
def __init__(self, *args, **kwargs) -> None:
4044
if args:
@@ -51,7 +55,9 @@ def __init__(self, *args, **kwargs) -> None:
5155
super().__init__(**kwargs)
5256

5357
@model_serializer
54-
def unwrap_actual_instance(self) -> Optional[Union[List[SupportedLanguage], bool]]:
58+
def unwrap_actual_instance(
59+
self,
60+
) -> Optional[Union[BooleanString, List[SupportedLanguage], bool]]:
5561
"""
5662
Unwraps the `actual_instance` when calling the `to_json` method.
5763
"""
@@ -75,15 +81,21 @@ def from_json(cls, json_str: str) -> Self:
7581
except (ValidationError, ValueError) as e:
7682
error_messages.append(str(e))
7783
try:
78-
instance.oneof_schema_2_validator = loads(json_str)
79-
instance.actual_instance = instance.oneof_schema_2_validator
84+
instance.actual_instance = BooleanString.from_json(json_str)
85+
86+
return instance
87+
except (ValidationError, ValueError) as e:
88+
error_messages.append(str(e))
89+
try:
90+
instance.oneof_schema_3_validator = loads(json_str)
91+
instance.actual_instance = instance.oneof_schema_3_validator
8092

8193
return instance
8294
except (ValidationError, ValueError) as e:
8395
error_messages.append(str(e))
8496

8597
raise ValueError(
86-
"No match found when deserializing the JSON string into IgnorePlurals with oneOf schemas: List[SupportedLanguage], bool. Details: "
98+
"No match found when deserializing the JSON string into IgnorePlurals with oneOf schemas: BooleanString, List[SupportedLanguage], bool. Details: "
8799
+ ", ".join(error_messages)
88100
)
89101

0 commit comments

Comments
 (0)