From c1179cb7848e3d01bf9fad747ece37f1975138a0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 3 Apr 2026 05:00:35 +0000 Subject: [PATCH] feat: Updated OpenAPI spec --- .../Guardrails.GuardClient.CreateGuard.g.cs | 1 - .../Guardrails.GuardClient.DeleteGuard.g.cs | 1 - .../Guardrails.GuardClient.GetGuard.g.cs | 1 - ...uardrails.GuardClient.GetGuardHistory.g.cs | 1 - .../Guardrails.GuardClient.GetGuards.g.cs | 1 - .../Guardrails.GuardClient.UpdateGuard.g.cs | 1 - ...ils.OpenaiClient.OpenaiChatCompletion.g.cs | 1 - .../Generated/Guardrails.Polyfills.g.cs | 126 +++++++++++++++++- ...rails.ServiceHealthClient.HealthCheck.g.cs | 1 - .../Guardrails.ValidateClient.Validate.g.cs | 1 - 10 files changed, 124 insertions(+), 11 deletions(-) diff --git a/src/libs/Guardrails/Generated/Guardrails.GuardClient.CreateGuard.g.cs b/src/libs/Guardrails/Generated/Guardrails.GuardClient.CreateGuard.g.cs index f8a30dd..05cf5af 100644 --- a/src/libs/Guardrails/Generated/Guardrails.GuardClient.CreateGuard.g.cs +++ b/src/libs/Guardrails/Generated/Guardrails.GuardClient.CreateGuard.g.cs @@ -177,7 +177,6 @@ partial void ProcessCreateGuardResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/Guardrails/Generated/Guardrails.GuardClient.DeleteGuard.g.cs b/src/libs/Guardrails/Generated/Guardrails.GuardClient.DeleteGuard.g.cs index c67ed03..967abcd 100644 --- a/src/libs/Guardrails/Generated/Guardrails.GuardClient.DeleteGuard.g.cs +++ b/src/libs/Guardrails/Generated/Guardrails.GuardClient.DeleteGuard.g.cs @@ -168,7 +168,6 @@ partial void ProcessDeleteGuardResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/Guardrails/Generated/Guardrails.GuardClient.GetGuard.g.cs b/src/libs/Guardrails/Generated/Guardrails.GuardClient.GetGuard.g.cs index 9a1cc37..20b6da8 100644 --- a/src/libs/Guardrails/Generated/Guardrails.GuardClient.GetGuard.g.cs +++ b/src/libs/Guardrails/Generated/Guardrails.GuardClient.GetGuard.g.cs @@ -177,7 +177,6 @@ partial void ProcessGetGuardResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/Guardrails/Generated/Guardrails.GuardClient.GetGuardHistory.g.cs b/src/libs/Guardrails/Generated/Guardrails.GuardClient.GetGuardHistory.g.cs index ec5e7f6..6314afb 100644 --- a/src/libs/Guardrails/Generated/Guardrails.GuardClient.GetGuardHistory.g.cs +++ b/src/libs/Guardrails/Generated/Guardrails.GuardClient.GetGuardHistory.g.cs @@ -174,7 +174,6 @@ partial void ProcessGetGuardHistoryResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/Guardrails/Generated/Guardrails.GuardClient.GetGuards.g.cs b/src/libs/Guardrails/Generated/Guardrails.GuardClient.GetGuards.g.cs index 411ec05..67b09ed 100644 --- a/src/libs/Guardrails/Generated/Guardrails.GuardClient.GetGuards.g.cs +++ b/src/libs/Guardrails/Generated/Guardrails.GuardClient.GetGuards.g.cs @@ -162,7 +162,6 @@ partial void ProcessGetGuardsResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/Guardrails/Generated/Guardrails.GuardClient.UpdateGuard.g.cs b/src/libs/Guardrails/Generated/Guardrails.GuardClient.UpdateGuard.g.cs index 26f4031..b1a52dc 100644 --- a/src/libs/Guardrails/Generated/Guardrails.GuardClient.UpdateGuard.g.cs +++ b/src/libs/Guardrails/Generated/Guardrails.GuardClient.UpdateGuard.g.cs @@ -183,7 +183,6 @@ partial void ProcessUpdateGuardResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/Guardrails/Generated/Guardrails.OpenaiClient.OpenaiChatCompletion.g.cs b/src/libs/Guardrails/Generated/Guardrails.OpenaiClient.OpenaiChatCompletion.g.cs index d28aef1..80c15dc 100644 --- a/src/libs/Guardrails/Generated/Guardrails.OpenaiClient.OpenaiChatCompletion.g.cs +++ b/src/libs/Guardrails/Generated/Guardrails.OpenaiClient.OpenaiChatCompletion.g.cs @@ -183,7 +183,6 @@ partial void ProcessOpenaiChatCompletionResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/Guardrails/Generated/Guardrails.Polyfills.g.cs b/src/libs/Guardrails/Generated/Guardrails.Polyfills.g.cs index 8c1c9fa..2eb8e37 100644 --- a/src/libs/Guardrails/Generated/Guardrails.Polyfills.g.cs +++ b/src/libs/Guardrails/Generated/Guardrails.Polyfills.g.cs @@ -1,5 +1,4 @@ -#if !NET6_0_OR_GREATER #nullable enable namespace Guardrails @@ -9,6 +8,7 @@ namespace Guardrails /// 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/Guardrails/Generated/Guardrails.ServiceHealthClient.HealthCheck.g.cs b/src/libs/Guardrails/Generated/Guardrails.ServiceHealthClient.HealthCheck.g.cs index ea35974..40a26d7 100644 --- a/src/libs/Guardrails/Generated/Guardrails.ServiceHealthClient.HealthCheck.g.cs +++ b/src/libs/Guardrails/Generated/Guardrails.ServiceHealthClient.HealthCheck.g.cs @@ -162,7 +162,6 @@ partial void ProcessHealthCheckResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken diff --git a/src/libs/Guardrails/Generated/Guardrails.ValidateClient.Validate.g.cs b/src/libs/Guardrails/Generated/Guardrails.ValidateClient.Validate.g.cs index a8d8111..a4ab81f 100644 --- a/src/libs/Guardrails/Generated/Guardrails.ValidateClient.Validate.g.cs +++ b/src/libs/Guardrails/Generated/Guardrails.ValidateClient.Validate.g.cs @@ -195,7 +195,6 @@ partial void ProcessValidateResponseContent( try { __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( #if NET5_0_OR_GREATER cancellationToken