Skip to content

Commit

Permalink
fix: loose type (generated)
Browse files Browse the repository at this point in the history
Co-authored-by: shortcuts <vannicattec@gmail.com>
  • Loading branch information
algolia-bot and shortcuts committed Oct 30, 2024
1 parent cd76f05 commit 0fce422
Show file tree
Hide file tree
Showing 59 changed files with 479 additions and 206 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ public AuthInput(AuthAlgoliaInsights actualInstance)
ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
}

/// <summary>
/// Initializes a new instance of the AuthInput class
/// with a Dictionary{string, string}
/// </summary>
/// <param name="actualInstance">An instance of Dictionary&lt;string, string&gt;.</param>
public AuthInput(Dictionary<string, string> actualInstance)
{
ActualInstance = actualInstance;
}


/// <summary>
/// Gets or Sets ActualInstance
Expand Down Expand Up @@ -146,6 +156,16 @@ public AuthAlgoliaInsights AsAuthAlgoliaInsights()
return (AuthAlgoliaInsights)ActualInstance;
}

/// <summary>
/// Get the actual instance of `Dictionary{string, string}`. If the actual instance is not `Dictionary{string, string}`,
/// the InvalidClassException will be thrown
/// </summary>
/// <returns>An instance of Dictionary&lt;string, string&gt;</returns>
public Dictionary<string, string> AsDictionaryString()
{
return (Dictionary<string, string>)ActualInstance;
}


/// <summary>
/// Check if the actual instance is of `AuthOAuth` type.
Expand Down Expand Up @@ -201,6 +221,15 @@ public bool IsAuthAlgoliaInsights()
return ActualInstance.GetType() == typeof(AuthAlgoliaInsights);
}

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

/// <summary>
/// Returns the string presentation of the object
/// </summary>
Expand Down Expand Up @@ -357,6 +386,18 @@ public override AuthInput Read(ref Utf8JsonReader reader, Type typeToConvert, Js
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into AuthAlgoliaInsights: {exception}");
}
}
if (root.ValueKind == JsonValueKind.Object)
{
try
{
return new AuthInput(jsonDocument.Deserialize<Dictionary<string, string>>(JsonConfig.Options));
}
catch (Exception exception)
{
// deserialization failed, try the next one
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into Dictionary<string, string>: {exception}");
}
}
throw new InvalidDataException($"The JSON string cannot be deserialized into any schema defined.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public enum AuthenticationType
/// Enum AlgoliaInsights for value: algoliaInsights
/// </summary>
[JsonPropertyName("algoliaInsights")]
AlgoliaInsights = 6
AlgoliaInsights = 6,

/// <summary>
/// Enum Secrets for value: secrets
/// </summary>
[JsonPropertyName("secrets")]
Secrets = 7
}

4 changes: 2 additions & 2 deletions clients/algoliasearch-client-go/algolia/abtesting/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions clients/algoliasearch-client-go/algolia/analytics/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions clients/algoliasearch-client-go/algolia/insights/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions clients/algoliasearch-client-go/algolia/monitoring/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions clients/algoliasearch-client-go/algolia/recommend/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions clients/algoliasearch-client-go/algolia/search/api_search.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions clients/algoliasearch-client-go/algolia/search/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0fce422

Please sign in to comment.