diff --git a/algoliasearch/recommend/models/highlight_result.py b/algoliasearch/recommend/models/highlight_result.py index ff9d5069f..fae785a74 100644 --- a/algoliasearch/recommend/models/highlight_result.py +++ b/algoliasearch/recommend/models/highlight_result.py @@ -26,26 +26,17 @@ class HighlightResult(BaseModel): HighlightResult """ - oneof_schema_1_validator: Optional[Dict[str, HighlightResult]] = Field( + oneof_schema_1_validator: Optional[HighlightResultOption] = None + oneof_schema_2_validator: Optional[Dict[str, HighlightResult]] = Field( default=None, description="Surround words that match the query with HTML tags for highlighting.", ) - oneof_schema_2_validator: Optional[HighlightResultOption] = None - oneof_schema_3_validator: Optional[Dict[str, HighlightResultOption]] = Field( - default=None, - description="Surround words that match the query with HTML tags for highlighting.", - ) - oneof_schema_4_validator: Optional[List[HighlightResultOption]] = Field( + oneof_schema_3_validator: Optional[List[HighlightResult]] = Field( default=None, description="Surround words that match the query with HTML tags for highlighting.", ) actual_instance: Optional[ - Union[ - Dict[str, HighlightResultOption], - Dict[str, HighlightResult], - HighlightResultOption, - List[HighlightResultOption], - ] + Union[Dict[str, HighlightResult], HighlightResultOption, List[HighlightResult]] ] = None def __init__(self, *args, **kwargs) -> None: @@ -66,12 +57,7 @@ def __init__(self, *args, **kwargs) -> None: def unwrap_actual_instance( self, ) -> Optional[ - Union[ - Dict[str, HighlightResultOption], - Dict[str, HighlightResult], - HighlightResultOption, - List[HighlightResultOption], - ] + Union[Dict[str, HighlightResult], HighlightResultOption, List[HighlightResult]] ]: """ Unwraps the `actual_instance` when calling the `to_json` method. @@ -89,14 +75,14 @@ def from_json(cls, json_str: str) -> Self: error_messages = [] try: - instance.oneof_schema_1_validator = loads(json_str) - instance.actual_instance = instance.oneof_schema_1_validator + instance.actual_instance = HighlightResultOption.from_json(json_str) return instance except (ValidationError, ValueError) as e: error_messages.append(str(e)) try: - instance.actual_instance = HighlightResultOption.from_json(json_str) + instance.oneof_schema_2_validator = loads(json_str) + instance.actual_instance = instance.oneof_schema_2_validator return instance except (ValidationError, ValueError) as e: @@ -105,19 +91,12 @@ def from_json(cls, json_str: str) -> Self: instance.oneof_schema_3_validator = loads(json_str) instance.actual_instance = instance.oneof_schema_3_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - try: - instance.oneof_schema_4_validator = loads(json_str) - instance.actual_instance = instance.oneof_schema_4_validator - return instance except (ValidationError, ValueError) as e: error_messages.append(str(e)) raise ValueError( - "No match found when deserializing the JSON string into HighlightResult with oneOf schemas: Dict[str, HighlightResultOption], Dict[str, HighlightResult], HighlightResultOption, List[HighlightResultOption]. Details: " + "No match found when deserializing the JSON string into HighlightResult with oneOf schemas: Dict[str, HighlightResult], HighlightResultOption, List[HighlightResult]. Details: " + ", ".join(error_messages) ) diff --git a/algoliasearch/recommend/models/recommendations_results.py b/algoliasearch/recommend/models/recommendations_results.py index f7e153e3b..b5ed604ea 100644 --- a/algoliasearch/recommend/models/recommendations_results.py +++ b/algoliasearch/recommend/models/recommendations_results.py @@ -145,15 +145,17 @@ class RecommendationsResults(BaseModel): description="Whether automatic events collection is enabled for the application.", alias="_automaticInsights", ) - page: Annotated[int, Field(strict=True, ge=0)] = Field( - description="Page of search results to retrieve." + page: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field( + default=0, description="Page of search results to retrieve." ) - nb_hits: StrictInt = Field(description="Number of results (hits).", alias="nbHits") - nb_pages: StrictInt = Field( - description="Number of pages of results.", alias="nbPages" + nb_hits: Optional[StrictInt] = Field( + default=None, description="Number of results (hits).", alias="nbHits" ) - hits_per_page: Annotated[int, Field(le=1000, strict=True, ge=1)] = Field( - description="Number of hits per page.", alias="hitsPerPage" + nb_pages: Optional[StrictInt] = Field( + default=None, description="Number of pages of results.", alias="nbPages" + ) + hits_per_page: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = Field( + default=20, description="Number of hits per page.", alias="hitsPerPage" ) hits: List[RecommendationsHit] diff --git a/algoliasearch/recommend/models/snippet_result.py b/algoliasearch/recommend/models/snippet_result.py index 596d46142..3253a422c 100644 --- a/algoliasearch/recommend/models/snippet_result.py +++ b/algoliasearch/recommend/models/snippet_result.py @@ -26,26 +26,17 @@ class SnippetResult(BaseModel): SnippetResult """ - oneof_schema_1_validator: Optional[Dict[str, SnippetResult]] = Field( + oneof_schema_1_validator: Optional[SnippetResultOption] = None + oneof_schema_2_validator: Optional[Dict[str, SnippetResult]] = Field( default=None, description="Snippets that show the context around a matching search query.", ) - oneof_schema_2_validator: Optional[SnippetResultOption] = None - oneof_schema_3_validator: Optional[Dict[str, SnippetResultOption]] = Field( - default=None, - description="Snippets that show the context around a matching search query.", - ) - oneof_schema_4_validator: Optional[List[SnippetResultOption]] = Field( + oneof_schema_3_validator: Optional[List[SnippetResult]] = Field( default=None, description="Snippets that show the context around a matching search query.", ) actual_instance: Optional[ - Union[ - Dict[str, SnippetResultOption], - Dict[str, SnippetResult], - List[SnippetResultOption], - SnippetResultOption, - ] + Union[Dict[str, SnippetResult], List[SnippetResult], SnippetResultOption] ] = None def __init__(self, *args, **kwargs) -> None: @@ -66,12 +57,7 @@ def __init__(self, *args, **kwargs) -> None: def unwrap_actual_instance( self, ) -> Optional[ - Union[ - Dict[str, SnippetResultOption], - Dict[str, SnippetResult], - List[SnippetResultOption], - SnippetResultOption, - ] + Union[Dict[str, SnippetResult], List[SnippetResult], SnippetResultOption] ]: """ Unwraps the `actual_instance` when calling the `to_json` method. @@ -89,14 +75,14 @@ def from_json(cls, json_str: str) -> Self: error_messages = [] try: - instance.oneof_schema_1_validator = loads(json_str) - instance.actual_instance = instance.oneof_schema_1_validator + instance.actual_instance = SnippetResultOption.from_json(json_str) return instance except (ValidationError, ValueError) as e: error_messages.append(str(e)) try: - instance.actual_instance = SnippetResultOption.from_json(json_str) + instance.oneof_schema_2_validator = loads(json_str) + instance.actual_instance = instance.oneof_schema_2_validator return instance except (ValidationError, ValueError) as e: @@ -105,19 +91,12 @@ def from_json(cls, json_str: str) -> Self: instance.oneof_schema_3_validator = loads(json_str) instance.actual_instance = instance.oneof_schema_3_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - try: - instance.oneof_schema_4_validator = loads(json_str) - instance.actual_instance = instance.oneof_schema_4_validator - return instance except (ValidationError, ValueError) as e: error_messages.append(str(e)) raise ValueError( - "No match found when deserializing the JSON string into SnippetResult with oneOf schemas: Dict[str, SnippetResultOption], Dict[str, SnippetResult], List[SnippetResultOption], SnippetResultOption. Details: " + "No match found when deserializing the JSON string into SnippetResult with oneOf schemas: Dict[str, SnippetResult], List[SnippetResult], SnippetResultOption. Details: " + ", ".join(error_messages) ) diff --git a/algoliasearch/search/models/highlight_result.py b/algoliasearch/search/models/highlight_result.py index 0e3059830..d12d561c9 100644 --- a/algoliasearch/search/models/highlight_result.py +++ b/algoliasearch/search/models/highlight_result.py @@ -26,26 +26,17 @@ class HighlightResult(BaseModel): HighlightResult """ - oneof_schema_1_validator: Optional[Dict[str, HighlightResult]] = Field( + oneof_schema_1_validator: Optional[HighlightResultOption] = None + oneof_schema_2_validator: Optional[Dict[str, HighlightResult]] = Field( default=None, description="Surround words that match the query with HTML tags for highlighting.", ) - oneof_schema_2_validator: Optional[HighlightResultOption] = None - oneof_schema_3_validator: Optional[Dict[str, HighlightResultOption]] = Field( - default=None, - description="Surround words that match the query with HTML tags for highlighting.", - ) - oneof_schema_4_validator: Optional[List[HighlightResultOption]] = Field( + oneof_schema_3_validator: Optional[List[HighlightResult]] = Field( default=None, description="Surround words that match the query with HTML tags for highlighting.", ) actual_instance: Optional[ - Union[ - Dict[str, HighlightResultOption], - Dict[str, HighlightResult], - HighlightResultOption, - List[HighlightResultOption], - ] + Union[Dict[str, HighlightResult], HighlightResultOption, List[HighlightResult]] ] = None def __init__(self, *args, **kwargs) -> None: @@ -66,12 +57,7 @@ def __init__(self, *args, **kwargs) -> None: def unwrap_actual_instance( self, ) -> Optional[ - Union[ - Dict[str, HighlightResultOption], - Dict[str, HighlightResult], - HighlightResultOption, - List[HighlightResultOption], - ] + Union[Dict[str, HighlightResult], HighlightResultOption, List[HighlightResult]] ]: """ Unwraps the `actual_instance` when calling the `to_json` method. @@ -89,14 +75,14 @@ def from_json(cls, json_str: str) -> Self: error_messages = [] try: - instance.oneof_schema_1_validator = loads(json_str) - instance.actual_instance = instance.oneof_schema_1_validator + instance.actual_instance = HighlightResultOption.from_json(json_str) return instance except (ValidationError, ValueError) as e: error_messages.append(str(e)) try: - instance.actual_instance = HighlightResultOption.from_json(json_str) + instance.oneof_schema_2_validator = loads(json_str) + instance.actual_instance = instance.oneof_schema_2_validator return instance except (ValidationError, ValueError) as e: @@ -105,19 +91,12 @@ def from_json(cls, json_str: str) -> Self: instance.oneof_schema_3_validator = loads(json_str) instance.actual_instance = instance.oneof_schema_3_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - try: - instance.oneof_schema_4_validator = loads(json_str) - instance.actual_instance = instance.oneof_schema_4_validator - return instance except (ValidationError, ValueError) as e: error_messages.append(str(e)) raise ValueError( - "No match found when deserializing the JSON string into HighlightResult with oneOf schemas: Dict[str, HighlightResultOption], Dict[str, HighlightResult], HighlightResultOption, List[HighlightResultOption]. Details: " + "No match found when deserializing the JSON string into HighlightResult with oneOf schemas: Dict[str, HighlightResult], HighlightResultOption, List[HighlightResult]. Details: " + ", ".join(error_messages) ) diff --git a/algoliasearch/search/models/search_response.py b/algoliasearch/search/models/search_response.py index 3e76d2e7e..c599262b8 100644 --- a/algoliasearch/search/models/search_response.py +++ b/algoliasearch/search/models/search_response.py @@ -145,15 +145,17 @@ class SearchResponse(BaseModel): description="Whether automatic events collection is enabled for the application.", alias="_automaticInsights", ) - page: Annotated[int, Field(strict=True, ge=0)] = Field( - description="Page of search results to retrieve." + page: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field( + default=0, description="Page of search results to retrieve." ) - nb_hits: StrictInt = Field(description="Number of results (hits).", alias="nbHits") - nb_pages: StrictInt = Field( - description="Number of pages of results.", alias="nbPages" + nb_hits: Optional[StrictInt] = Field( + default=None, description="Number of results (hits).", alias="nbHits" ) - hits_per_page: Annotated[int, Field(le=1000, strict=True, ge=1)] = Field( - description="Number of hits per page.", alias="hitsPerPage" + nb_pages: Optional[StrictInt] = Field( + default=None, description="Number of pages of results.", alias="nbPages" + ) + hits_per_page: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = Field( + default=20, description="Number of hits per page.", alias="hitsPerPage" ) hits: List[Hit] = Field( description="Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting. " diff --git a/algoliasearch/search/models/snippet_result.py b/algoliasearch/search/models/snippet_result.py index f1b11da37..5c9146b48 100644 --- a/algoliasearch/search/models/snippet_result.py +++ b/algoliasearch/search/models/snippet_result.py @@ -26,26 +26,17 @@ class SnippetResult(BaseModel): SnippetResult """ - oneof_schema_1_validator: Optional[Dict[str, SnippetResult]] = Field( + oneof_schema_1_validator: Optional[SnippetResultOption] = None + oneof_schema_2_validator: Optional[Dict[str, SnippetResult]] = Field( default=None, description="Snippets that show the context around a matching search query.", ) - oneof_schema_2_validator: Optional[SnippetResultOption] = None - oneof_schema_3_validator: Optional[Dict[str, SnippetResultOption]] = Field( - default=None, - description="Snippets that show the context around a matching search query.", - ) - oneof_schema_4_validator: Optional[List[SnippetResultOption]] = Field( + oneof_schema_3_validator: Optional[List[SnippetResult]] = Field( default=None, description="Snippets that show the context around a matching search query.", ) actual_instance: Optional[ - Union[ - Dict[str, SnippetResultOption], - Dict[str, SnippetResult], - List[SnippetResultOption], - SnippetResultOption, - ] + Union[Dict[str, SnippetResult], List[SnippetResult], SnippetResultOption] ] = None def __init__(self, *args, **kwargs) -> None: @@ -66,12 +57,7 @@ def __init__(self, *args, **kwargs) -> None: def unwrap_actual_instance( self, ) -> Optional[ - Union[ - Dict[str, SnippetResultOption], - Dict[str, SnippetResult], - List[SnippetResultOption], - SnippetResultOption, - ] + Union[Dict[str, SnippetResult], List[SnippetResult], SnippetResultOption] ]: """ Unwraps the `actual_instance` when calling the `to_json` method. @@ -89,14 +75,14 @@ def from_json(cls, json_str: str) -> Self: error_messages = [] try: - instance.oneof_schema_1_validator = loads(json_str) - instance.actual_instance = instance.oneof_schema_1_validator + instance.actual_instance = SnippetResultOption.from_json(json_str) return instance except (ValidationError, ValueError) as e: error_messages.append(str(e)) try: - instance.actual_instance = SnippetResultOption.from_json(json_str) + instance.oneof_schema_2_validator = loads(json_str) + instance.actual_instance = instance.oneof_schema_2_validator return instance except (ValidationError, ValueError) as e: @@ -105,19 +91,12 @@ def from_json(cls, json_str: str) -> Self: instance.oneof_schema_3_validator = loads(json_str) instance.actual_instance = instance.oneof_schema_3_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - try: - instance.oneof_schema_4_validator = loads(json_str) - instance.actual_instance = instance.oneof_schema_4_validator - return instance except (ValidationError, ValueError) as e: error_messages.append(str(e)) raise ValueError( - "No match found when deserializing the JSON string into SnippetResult with oneOf schemas: Dict[str, SnippetResultOption], Dict[str, SnippetResult], List[SnippetResultOption], SnippetResultOption. Details: " + "No match found when deserializing the JSON string into SnippetResult with oneOf schemas: Dict[str, SnippetResult], List[SnippetResult], SnippetResultOption. Details: " + ", ".join(error_messages) )