diff --git a/src/libs/Serper/Generated/Serper.Polyfills.g.cs b/src/libs/Serper/Generated/Serper.Polyfills.g.cs
index 8ad4558..c5982e9 100644
--- a/src/libs/Serper/Generated/Serper.Polyfills.g.cs
+++ b/src/libs/Serper/Generated/Serper.Polyfills.g.cs
@@ -1,5 +1,4 @@
-#if !NET6_0_OR_GREATER
#nullable enable
namespace Serper
@@ -9,6 +8,7 @@ namespace Serper
///
public static partial class AutoSdkPolyfills
{
+#if !NET6_0_OR_GREATER
///
///
///
@@ -48,6 +48,128 @@ public static partial class AutoSdkPolyfills
content = content ?? throw new global::System.ArgumentNullException(nameof(content));
return content.ReadAsByteArrayAsync();
}
+#endif
+
+ ///
+ /// Creates a JSON request content instance.
+ ///
+ public static global::System.Net.Http.HttpContent CreateJsonContent(
+ T inputValue,
+ string mediaType,
+ global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions)
+ {
+ if (string.IsNullOrWhiteSpace(mediaType))
+ {
+ throw new global::System.ArgumentException("Media type is required.", nameof(mediaType));
+ }
+
+#if NET5_0_OR_GREATER
+ return global::System.Net.Http.Json.JsonContent.Create(
+ inputValue: inputValue,
+ mediaType: new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType),
+ options: jsonSerializerOptions);
+#else
+ var json = global::System.Text.Json.JsonSerializer.Serialize(inputValue, jsonSerializerOptions);
+ var stringContent = new global::System.Net.Http.StringContent(
+ content: json,
+ encoding: global::System.Text.Encoding.UTF8);
+ stringContent.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType)
+ {
+ CharSet = global::System.Text.Encoding.UTF8.WebName,
+ };
+ return stringContent;
+#endif
+ }
+
+ ///
+ /// Creates a JSON request content instance using a source-generated serializer context.
+ ///
+ public static global::System.Net.Http.HttpContent CreateJsonContent(
+ object? inputValue,
+ global::System.Type inputType,
+ string mediaType,
+ global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
+ {
+ inputType = inputType ?? throw new global::System.ArgumentNullException(nameof(inputType));
+ jsonSerializerContext = jsonSerializerContext ?? throw new global::System.ArgumentNullException(nameof(jsonSerializerContext));
+
+ if (string.IsNullOrWhiteSpace(mediaType))
+ {
+ throw new global::System.ArgumentException("Media type is required.", nameof(mediaType));
+ }
+
+#if NET5_0_OR_GREATER
+ var jsonTypeInfo = jsonSerializerContext.GetTypeInfo(inputType) ??
+ throw new global::System.InvalidOperationException($"No JsonTypeInfo registered for '{inputType}'.");
+ return global::System.Net.Http.Json.JsonContent.Create(
+ inputValue: inputValue,
+ jsonTypeInfo: jsonTypeInfo,
+ mediaType: new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType));
+#else
+ var json = global::System.Text.Json.JsonSerializer.Serialize(
+ value: inputValue,
+ inputType: inputType,
+ jsonSerializerContext);
+ var stringContent = new global::System.Net.Http.StringContent(
+ content: json,
+ encoding: global::System.Text.Encoding.UTF8);
+ stringContent.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType)
+ {
+ CharSet = global::System.Text.Encoding.UTF8.WebName,
+ };
+ return stringContent;
+#endif
+ }
+
+ ///
+ /// Reads JSON content into the specified type using serializer options.
+ ///
+ public static async global::System.Threading.Tasks.Task ReadFromJsonAsync(
+ this global::System.Net.Http.HttpContent content,
+ global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions,
+ global::System.Threading.CancellationToken cancellationToken)
+ {
+ content = content ?? throw new global::System.ArgumentNullException(nameof(content));
+
+#if NET5_0_OR_GREATER
+ return await global::System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync(
+ content,
+ jsonSerializerOptions,
+ cancellationToken).ConfigureAwait(false);
+#else
+ using var stream = await AutoSdkPolyfills.ReadAsStreamAsync(content, cancellationToken).ConfigureAwait(false);
+ return await global::System.Text.Json.JsonSerializer.DeserializeAsync(
+ utf8Json: stream,
+ options: jsonSerializerOptions,
+ cancellationToken: cancellationToken).ConfigureAwait(false);
+#endif
+ }
+
+ ///
+ /// Reads JSON content into the specified type using a source-generated serializer context.
+ ///
+ public static async global::System.Threading.Tasks.Task ReadFromJsonAsync(
+ this global::System.Net.Http.HttpContent content,
+ global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext,
+ global::System.Threading.CancellationToken cancellationToken)
+ {
+ content = content ?? throw new global::System.ArgumentNullException(nameof(content));
+ jsonSerializerContext = jsonSerializerContext ?? throw new global::System.ArgumentNullException(nameof(jsonSerializerContext));
+
+#if NET5_0_OR_GREATER
+ return (T?)await global::System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync(
+ content,
+ typeof(T),
+ jsonSerializerContext,
+ cancellationToken).ConfigureAwait(false);
+#else
+ using var stream = await AutoSdkPolyfills.ReadAsStreamAsync(content, cancellationToken).ConfigureAwait(false);
+ return (T?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(
+ utf8Json: stream,
+ returnType: typeof(T),
+ jsonSerializerContext,
+ cancellationToken: cancellationToken).ConfigureAwait(false);
+#endif
+ }
}
}
-#endif
\ No newline at end of file
diff --git a/src/libs/Serper/Generated/Serper.SerperClient.Autocomplete.g.cs b/src/libs/Serper/Generated/Serper.SerperClient.Autocomplete.g.cs
index a086404..1d4278c 100644
--- a/src/libs/Serper/Generated/Serper.SerperClient.Autocomplete.g.cs
+++ b/src/libs/Serper/Generated/Serper.SerperClient.Autocomplete.g.cs
@@ -140,7 +140,6 @@ partial void ProcessAutocompleteResponseContent(
try
{
__response.EnsureSuccessStatusCode();
-
using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
diff --git a/src/libs/Serper/Generated/Serper.SerperClient.ImageSearch.g.cs b/src/libs/Serper/Generated/Serper.SerperClient.ImageSearch.g.cs
index bca2758..266d7a5 100644
--- a/src/libs/Serper/Generated/Serper.SerperClient.ImageSearch.g.cs
+++ b/src/libs/Serper/Generated/Serper.SerperClient.ImageSearch.g.cs
@@ -138,7 +138,6 @@ partial void ProcessImageSearchResponseContent(
try
{
__response.EnsureSuccessStatusCode();
-
using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
diff --git a/src/libs/Serper/Generated/Serper.SerperClient.NewsSearch.g.cs b/src/libs/Serper/Generated/Serper.SerperClient.NewsSearch.g.cs
index eaf9c2a..7d51010 100644
--- a/src/libs/Serper/Generated/Serper.SerperClient.NewsSearch.g.cs
+++ b/src/libs/Serper/Generated/Serper.SerperClient.NewsSearch.g.cs
@@ -138,7 +138,6 @@ partial void ProcessNewsSearchResponseContent(
try
{
__response.EnsureSuccessStatusCode();
-
using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
diff --git a/src/libs/Serper/Generated/Serper.SerperClient.PatentSearch.g.cs b/src/libs/Serper/Generated/Serper.SerperClient.PatentSearch.g.cs
index 248c601..40c138a 100644
--- a/src/libs/Serper/Generated/Serper.SerperClient.PatentSearch.g.cs
+++ b/src/libs/Serper/Generated/Serper.SerperClient.PatentSearch.g.cs
@@ -138,7 +138,6 @@ partial void ProcessPatentSearchResponseContent(
try
{
__response.EnsureSuccessStatusCode();
-
using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
diff --git a/src/libs/Serper/Generated/Serper.SerperClient.PlacesSearch.g.cs b/src/libs/Serper/Generated/Serper.SerperClient.PlacesSearch.g.cs
index fe8238e..6a9b236 100644
--- a/src/libs/Serper/Generated/Serper.SerperClient.PlacesSearch.g.cs
+++ b/src/libs/Serper/Generated/Serper.SerperClient.PlacesSearch.g.cs
@@ -138,7 +138,6 @@ partial void ProcessPlacesSearchResponseContent(
try
{
__response.EnsureSuccessStatusCode();
-
using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
diff --git a/src/libs/Serper/Generated/Serper.SerperClient.ScholarSearch.g.cs b/src/libs/Serper/Generated/Serper.SerperClient.ScholarSearch.g.cs
index 23580f3..abf26e7 100644
--- a/src/libs/Serper/Generated/Serper.SerperClient.ScholarSearch.g.cs
+++ b/src/libs/Serper/Generated/Serper.SerperClient.ScholarSearch.g.cs
@@ -139,7 +139,6 @@ partial void ProcessScholarSearchResponseContent(
try
{
__response.EnsureSuccessStatusCode();
-
using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
diff --git a/src/libs/Serper/Generated/Serper.SerperClient.Search.g.cs b/src/libs/Serper/Generated/Serper.SerperClient.Search.g.cs
index f4ed139..013cce1 100644
--- a/src/libs/Serper/Generated/Serper.SerperClient.Search.g.cs
+++ b/src/libs/Serper/Generated/Serper.SerperClient.Search.g.cs
@@ -139,7 +139,6 @@ partial void ProcessSearchResponseContent(
try
{
__response.EnsureSuccessStatusCode();
-
using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
diff --git a/src/libs/Serper/Generated/Serper.SerperClient.ShoppingSearch.g.cs b/src/libs/Serper/Generated/Serper.SerperClient.ShoppingSearch.g.cs
index 3f5716c..b264879 100644
--- a/src/libs/Serper/Generated/Serper.SerperClient.ShoppingSearch.g.cs
+++ b/src/libs/Serper/Generated/Serper.SerperClient.ShoppingSearch.g.cs
@@ -138,7 +138,6 @@ partial void ProcessShoppingSearchResponseContent(
try
{
__response.EnsureSuccessStatusCode();
-
using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
diff --git a/src/libs/Serper/Generated/Serper.SerperClient.VideoSearch.g.cs b/src/libs/Serper/Generated/Serper.SerperClient.VideoSearch.g.cs
index 2de47dc..56961f8 100644
--- a/src/libs/Serper/Generated/Serper.SerperClient.VideoSearch.g.cs
+++ b/src/libs/Serper/Generated/Serper.SerperClient.VideoSearch.g.cs
@@ -138,7 +138,6 @@ partial void ProcessVideoSearchResponseContent(
try
{
__response.EnsureSuccessStatusCode();
-
using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken