Skip to content

Commit

Permalink
fix(specs): ignorePlurals can be a boolean string (#3620) (generated)…
Browse files Browse the repository at this point in the history
… [skip ci]

Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
  • Loading branch information
algolia-bot and millotp committed Aug 30, 2024
1 parent e09849e commit 07bbeee
Show file tree
Hide file tree
Showing 272 changed files with 1,991 additions and 2,311 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// 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.
//
using System;
using System.Text;
using System.Linq;
using System.Text.Json.Serialization;
using System.Collections.Generic;
using Algolia.Search.Serializer;
using System.Text.Json;

namespace Algolia.Search.Models.Recommend;

/// <summary>
/// Defines booleanString
/// </summary>
public enum BooleanString
{
/// <summary>
/// Enum True for value: true
/// </summary>
[JsonPropertyName("true")]
True = 1,

/// <summary>
/// Enum False for value: false
/// </summary>
[JsonPropertyName("false")]
False = 2
}

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public IgnorePlurals(List<SupportedLanguage> actualInstance)
ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
}

/// <summary>
/// Initializes a new instance of the IgnorePlurals class
/// with a BooleanString
/// </summary>
/// <param name="actualInstance">An instance of BooleanString.</param>
public IgnorePlurals(BooleanString actualInstance)
{
ActualInstance = actualInstance;
}

/// <summary>
/// Initializes a new instance of the IgnorePlurals class
/// with a bool
Expand All @@ -56,6 +66,16 @@ public List<SupportedLanguage> AsListSupportedLanguage()
return (List<SupportedLanguage>)ActualInstance;
}

/// <summary>
/// Get the actual instance of `BooleanString`. If the actual instance is not `BooleanString`,
/// the InvalidClassException will be thrown
/// </summary>
/// <returns>An instance of BooleanString</returns>
public BooleanString AsBooleanString()
{
return (BooleanString)ActualInstance;
}

/// <summary>
/// Get the actual instance of `bool`. If the actual instance is not `bool`,
/// the InvalidClassException will be thrown
Expand All @@ -76,6 +96,15 @@ public bool IsListSupportedLanguage()
return ActualInstance.GetType() == typeof(List<SupportedLanguage>);
}

/// <summary>
/// Check if the actual instance is of `BooleanString` type.
/// </summary>
/// <returns>Whether or not the instance is the type</returns>
public bool IsBooleanString()
{
return ActualInstance.GetType() == typeof(BooleanString);
}

/// <summary>
/// Check if the actual instance is of `bool` type.
/// </summary>
Expand Down Expand Up @@ -181,6 +210,18 @@ public override IgnorePlurals Read(ref Utf8JsonReader reader, Type typeToConvert
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into List<SupportedLanguage>: {exception}");
}
}
if (root.ValueKind == JsonValueKind.String)
{
try
{
return new IgnorePlurals(jsonDocument.Deserialize<BooleanString>(JsonConfig.Options));
}
catch (Exception exception)
{
// deserialization failed, try the next one
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into BooleanString: {exception}");
}
}
if (root.ValueKind == JsonValueKind.True || root.ValueKind == JsonValueKind.False)
{
try
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// 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.
//
using System;
using System.Text;
using System.Linq;
using System.Text.Json.Serialization;
using System.Collections.Generic;
using Algolia.Search.Serializer;
using System.Text.Json;

namespace Algolia.Search.Models.Search;

/// <summary>
/// Defines booleanString
/// </summary>
public enum BooleanString
{
/// <summary>
/// Enum True for value: true
/// </summary>
[JsonPropertyName("true")]
True = 1,

/// <summary>
/// Enum False for value: false
/// </summary>
[JsonPropertyName("false")]
False = 2
}

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public IgnorePlurals(List<SupportedLanguage> actualInstance)
ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
}

/// <summary>
/// Initializes a new instance of the IgnorePlurals class
/// with a BooleanString
/// </summary>
/// <param name="actualInstance">An instance of BooleanString.</param>
public IgnorePlurals(BooleanString actualInstance)
{
ActualInstance = actualInstance;
}

/// <summary>
/// Initializes a new instance of the IgnorePlurals class
/// with a bool
Expand All @@ -56,6 +66,16 @@ public List<SupportedLanguage> AsListSupportedLanguage()
return (List<SupportedLanguage>)ActualInstance;
}

/// <summary>
/// Get the actual instance of `BooleanString`. If the actual instance is not `BooleanString`,
/// the InvalidClassException will be thrown
/// </summary>
/// <returns>An instance of BooleanString</returns>
public BooleanString AsBooleanString()
{
return (BooleanString)ActualInstance;
}

/// <summary>
/// Get the actual instance of `bool`. If the actual instance is not `bool`,
/// the InvalidClassException will be thrown
Expand All @@ -76,6 +96,15 @@ public bool IsListSupportedLanguage()
return ActualInstance.GetType() == typeof(List<SupportedLanguage>);
}

/// <summary>
/// Check if the actual instance is of `BooleanString` type.
/// </summary>
/// <returns>Whether or not the instance is the type</returns>
public bool IsBooleanString()
{
return ActualInstance.GetType() == typeof(BooleanString);
}

/// <summary>
/// Check if the actual instance is of `bool` type.
/// </summary>
Expand Down Expand Up @@ -181,6 +210,18 @@ public override IgnorePlurals Read(ref Utf8JsonReader reader, Type typeToConvert
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into List<SupportedLanguage>: {exception}");
}
}
if (root.ValueKind == JsonValueKind.String)
{
try
{
return new IgnorePlurals(jsonDocument.Deserialize<BooleanString>(JsonConfig.Options));
}
catch (Exception exception)
{
// deserialization failed, try the next one
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into BooleanString: {exception}");
}
}
if (root.ValueKind == JsonValueKind.True || root.ValueKind == JsonValueKind.False)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export 'src/model/base_recommend_request.dart';
export 'src/model/base_search_params.dart';
export 'src/model/base_search_params_without_query.dart';
export 'src/model/base_search_response.dart';
export 'src/model/boolean_string.dart';
export 'src/model/bought_together_query.dart';
export 'src/model/browse_pagination.dart';
export 'src/model/browse_params_object.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:algoliasearch/src/model/base_recommend_request.dart';
import 'package:algoliasearch/src/model/base_search_params.dart';
import 'package:algoliasearch/src/model/base_search_params_without_query.dart';
import 'package:algoliasearch/src/model/base_search_response.dart';
import 'package:algoliasearch/src/model/boolean_string.dart';
import 'package:algoliasearch/src/model/bought_together_query.dart';
import 'package:algoliasearch/src/model/browse_pagination.dart';
import 'package:algoliasearch/src/model/browse_params_object.dart';
Expand Down Expand Up @@ -144,6 +145,8 @@ ReturnType deserialize<ReturnType, BaseType>(dynamic value, String targetType,
case 'BaseSearchResponse':
return BaseSearchResponse.fromJson(value as Map<String, dynamic>)
as ReturnType;
case 'BooleanString':
return BooleanString.fromJson(value) as ReturnType;
case 'BoughtTogetherQuery':
return BoughtTogetherQuery.fromJson(value as Map<String, dynamic>)
as ReturnType;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// 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.
// ignore_for_file: unused_element
import 'package:json_annotation/json_annotation.dart';

@JsonEnum(valueField: 'raw')
enum BooleanString {
true_(r'true'),
false_(r'false');

const BooleanString(this.raw);
final dynamic raw;

dynamic toJson() => raw;

static BooleanString fromJson(dynamic json) {
for (final value in values) {
if (value.raw == json) return value;
}
throw ArgumentError.value(json, "raw", "No enum value with that value");
}

@override
String toString() => raw.toString();
}
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ final class BrowseParamsObject {
final List<String>? disableTypoToleranceOnAttributes;

/// One of types:
/// - [BooleanString]
/// - [bool]
/// - [List<SupportedLanguage>]
@JsonKey(name: r'ignorePlurals')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ final class ConsequenceParams {
final List<String>? disableTypoToleranceOnAttributes;

/// One of types:
/// - [BooleanString]
/// - [bool]
/// - [List<SupportedLanguage>]
@JsonKey(name: r'ignorePlurals')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ final class FallbackParams {
final List<String>? disableTypoToleranceOnAttributes;

/// One of types:
/// - [BooleanString]
/// - [bool]
/// - [List<SupportedLanguage>]
@JsonKey(name: r'ignorePlurals')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ final class IndexSettings {
final List<String>? disableTypoToleranceOnAttributes;

/// One of types:
/// - [BooleanString]
/// - [bool]
/// - [List<SupportedLanguage>]
@JsonKey(name: r'ignorePlurals')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ final class IndexSettingsAsSearchParams {
final List<String>? disableTypoToleranceOnAttributes;

/// One of types:
/// - [BooleanString]
/// - [bool]
/// - [List<SupportedLanguage>]
@JsonKey(name: r'ignorePlurals')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ final class SearchForFacets {
final List<String>? disableTypoToleranceOnAttributes;

/// One of types:
/// - [BooleanString]
/// - [bool]
/// - [List<SupportedLanguage>]
@JsonKey(name: r'ignorePlurals')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ final class SearchForHits {
final List<String>? disableTypoToleranceOnAttributes;

/// One of types:
/// - [BooleanString]
/// - [bool]
/// - [List<SupportedLanguage>]
@JsonKey(name: r'ignorePlurals')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ final class SearchParams {
final List<String>? disableTypoToleranceOnAttributes;

/// One of types:
/// - [BooleanString]
/// - [bool]
/// - [List<SupportedLanguage>]
@JsonKey(name: r'ignorePlurals')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ final class SearchParamsObject {
final List<String>? disableTypoToleranceOnAttributes;

/// One of types:
/// - [BooleanString]
/// - [bool]
/// - [List<SupportedLanguage>]
@JsonKey(name: r'ignorePlurals')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ final class SettingsResponse {
final List<String>? disableTypoToleranceOnAttributes;

/// One of types:
/// - [BooleanString]
/// - [bool]
/// - [List<SupportedLanguage>]
@JsonKey(name: r'ignorePlurals')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export 'src/model/base_recommend_request.dart';
export 'src/model/base_search_params.dart';
export 'src/model/base_search_params_without_query.dart';
export 'src/model/base_search_response.dart';
export 'src/model/boolean_string.dart';
export 'src/model/bought_together_query.dart';
export 'src/model/condition.dart';
export 'src/model/consequence.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:algolia_client_recommend/src/model/base_recommend_request.dart';
import 'package:algolia_client_recommend/src/model/base_search_params.dart';
import 'package:algolia_client_recommend/src/model/base_search_params_without_query.dart';
import 'package:algolia_client_recommend/src/model/base_search_response.dart';
import 'package:algolia_client_recommend/src/model/boolean_string.dart';
import 'package:algolia_client_recommend/src/model/bought_together_query.dart';
import 'package:algolia_client_recommend/src/model/condition.dart';
import 'package:algolia_client_recommend/src/model/consequence.dart';
Expand Down Expand Up @@ -116,6 +117,8 @@ ReturnType deserialize<ReturnType, BaseType>(dynamic value, String targetType,
case 'BaseSearchResponse':
return BaseSearchResponse.fromJson(value as Map<String, dynamic>)
as ReturnType;
case 'BooleanString':
return BooleanString.fromJson(value) as ReturnType;
case 'BoughtTogetherQuery':
return BoughtTogetherQuery.fromJson(value as Map<String, dynamic>)
as ReturnType;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// 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.
// ignore_for_file: unused_element
import 'package:json_annotation/json_annotation.dart';

@JsonEnum(valueField: 'raw')
enum BooleanString {
true_(r'true'),
false_(r'false');

const BooleanString(this.raw);
final dynamic raw;

dynamic toJson() => raw;

static BooleanString fromJson(dynamic json) {
for (final value in values) {
if (value.raw == json) return value;
}
throw ArgumentError.value(json, "raw", "No enum value with that value");
}

@override
String toString() => raw.toString();
}
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ final class FallbackParams {
final List<String>? disableTypoToleranceOnAttributes;

/// One of types:
/// - [BooleanString]
/// - [bool]
/// - [List<SupportedLanguage>]
@JsonKey(name: r'ignorePlurals')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ final class IndexSettingsAsSearchParams {
final List<String>? disableTypoToleranceOnAttributes;

/// One of types:
/// - [BooleanString]
/// - [bool]
/// - [List<SupportedLanguage>]
@JsonKey(name: r'ignorePlurals')
Expand Down
Loading

0 comments on commit 07bbeee

Please sign in to comment.