From 02b8dc924b480e28f898926815b187c1ea8c5ab4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 5 Sep 2025 21:08:56 +0000 Subject: [PATCH] feat: Updated OpenAPI spec --- .../Recraft.IImageClient.VariateImage.g.cs | 41 +++ .../Recraft.ImageClient.VariateImage.g.cs | 242 ++++++++++++++++++ .../Recraft.JsonSerializerContextTypes.g.cs | 6 +- ...craft.Models.VariateImageRequest.Json.g.cs | 92 +++++++ .../Recraft.Models.VariateImageRequest.g.cs | 112 ++++++++ src/libs/Recraft/openapi.yaml | 40 +++ 6 files changed, 532 insertions(+), 1 deletion(-) create mode 100644 src/libs/Recraft/Generated/Recraft.IImageClient.VariateImage.g.cs create mode 100644 src/libs/Recraft/Generated/Recraft.ImageClient.VariateImage.g.cs create mode 100644 src/libs/Recraft/Generated/Recraft.Models.VariateImageRequest.Json.g.cs create mode 100644 src/libs/Recraft/Generated/Recraft.Models.VariateImageRequest.g.cs diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.VariateImage.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.VariateImage.g.cs new file mode 100644 index 0000000..6e96047 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.IImageClient.VariateImage.g.cs @@ -0,0 +1,41 @@ +#nullable enable + +namespace Recraft +{ + public partial interface IImageClient + { + /// + /// Variate Image + /// + /// + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task VariateImageAsync( + global::Recraft.VariateImageRequest request, + global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Variate Image + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task VariateImageAsync( + byte[] image, + string imagename, + global::Recraft.ImageSize size, + bool? expire = default, + global::Recraft.ImageFormat? imageFormat = default, + int? n = default, + int? randomSeed = default, + global::Recraft.ResponseFormat? responseFormat = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.VariateImage.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.VariateImage.g.cs new file mode 100644 index 0000000..ff31ca0 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.ImageClient.VariateImage.g.cs @@ -0,0 +1,242 @@ + +#nullable enable + +namespace Recraft +{ + public partial class ImageClient + { + partial void PrepareVariateImageArguments( + global::System.Net.Http.HttpClient httpClient, + global::Recraft.VariateImageRequest request); + partial void PrepareVariateImageRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + global::Recraft.VariateImageRequest request); + partial void ProcessVariateImageResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessVariateImageResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// Variate Image + /// + /// + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task VariateImageAsync( + global::Recraft.VariateImageRequest request, + global::System.Threading.CancellationToken cancellationToken = default) + { + request = request ?? throw new global::System.ArgumentNullException(nameof(request)); + + PrepareArguments( + client: HttpClient); + PrepareVariateImageArguments( + httpClient: HttpClient, + request: request); + + var __pathBuilder = new global::Recraft.PathBuilder( + path: "/v1/images/variateImage", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in Authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + using var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + if (request.Expire != default) + { + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"{request.Expire}"), + name: "expire"); + } + __httpRequestContent.Add( + content: new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty()), + name: "image", + fileName: request.Imagename ?? string.Empty); + if (request.ImageFormat != default) + { + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"{request.ImageFormat?.ToValueString()}"), + name: "image_format"); + } + if (request.N != default) + { + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"{request.N}"), + name: "n"); + } + if (request.RandomSeed != default) + { + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"{request.RandomSeed}"), + name: "random_seed"); + } + if (request.ResponseFormat != default) + { + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"{request.ResponseFormat?.ToValueString()}"), + name: "response_format"); + } + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"{request.Size.ToValueString()}"), + name: "size"); + __httpRequest.Content = __httpRequestContent; + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareVariateImageRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + using var __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: cancellationToken).ConfigureAwait(false); + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessVariateImageResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + + if (ReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( +#if NET5_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessVariateImageResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Recraft.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + + using var __content = await __response.Content.ReadAsStreamAsync( +#if NET5_0_OR_GREATER + cancellationToken +#endif + ).ConfigureAwait(false); + + return + await global::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + throw new global::Recraft.ApiException( + message: __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + } + + /// + /// Variate Image + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task VariateImageAsync( + byte[] image, + string imagename, + global::Recraft.ImageSize size, + bool? expire = default, + global::Recraft.ImageFormat? imageFormat = default, + int? n = default, + int? randomSeed = default, + global::Recraft.ResponseFormat? responseFormat = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __request = new global::Recraft.VariateImageRequest + { + Expire = expire, + Image = image, + Imagename = imagename, + ImageFormat = imageFormat, + N = n, + RandomSeed = randomSeed, + ResponseFormat = responseFormat, + Size = size, + }; + + return await VariateImageAsync( + request: __request, + cancellationToken: cancellationToken).ConfigureAwait(false); + } + } +} \ No newline at end of file diff --git a/src/libs/Recraft/Generated/Recraft.JsonSerializerContextTypes.g.cs b/src/libs/Recraft/Generated/Recraft.JsonSerializerContextTypes.g.cs index 082e020..0fbe1c2 100644 --- a/src/libs/Recraft/Generated/Recraft.JsonSerializerContextTypes.g.cs +++ b/src/libs/Recraft/Generated/Recraft.JsonSerializerContextTypes.g.cs @@ -206,6 +206,10 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public object? Type45 { get; set; } + public global::Recraft.VariateImageRequest? Type45 { get; set; } + /// + /// + /// + public object? Type46 { get; set; } } } \ No newline at end of file diff --git a/src/libs/Recraft/Generated/Recraft.Models.VariateImageRequest.Json.g.cs b/src/libs/Recraft/Generated/Recraft.Models.VariateImageRequest.Json.g.cs new file mode 100644 index 0000000..98fe8a6 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.Models.VariateImageRequest.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace Recraft +{ + public sealed partial class VariateImageRequest + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Recraft.VariateImageRequest? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Recraft.VariateImageRequest), + jsonSerializerContext) as global::Recraft.VariateImageRequest; + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Recraft.VariateImageRequest? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Recraft.VariateImageRequest), + jsonSerializerContext).ConfigureAwait(false)) as global::Recraft.VariateImageRequest; + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Recraft/Generated/Recraft.Models.VariateImageRequest.g.cs b/src/libs/Recraft/Generated/Recraft.Models.VariateImageRequest.g.cs new file mode 100644 index 0000000..8071fa9 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.Models.VariateImageRequest.g.cs @@ -0,0 +1,112 @@ + +#nullable enable + +namespace Recraft +{ + /// + /// + /// + public sealed partial class VariateImageRequest + { + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("expire")] + public bool? Expire { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("image")] + [global::System.Text.Json.Serialization.JsonRequired] + public required byte[] Image { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("imagename")] + [global::System.Text.Json.Serialization.JsonRequired] + public required string Imagename { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("image_format")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Recraft.JsonConverters.ImageFormatJsonConverter))] + public global::Recraft.ImageFormat? ImageFormat { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("n")] + public int? N { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("random_seed")] + public int? RandomSeed { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("response_format")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Recraft.JsonConverters.ResponseFormatJsonConverter))] + public global::Recraft.ResponseFormat? ResponseFormat { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("size")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Recraft.JsonConverters.ImageSizeJsonConverter))] + [global::System.Text.Json.Serialization.JsonRequired] + public required global::Recraft.ImageSize Size { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + /// + /// + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public VariateImageRequest( + byte[] image, + string imagename, + global::Recraft.ImageSize size, + bool? expire, + global::Recraft.ImageFormat? imageFormat, + int? n, + int? randomSeed, + global::Recraft.ResponseFormat? responseFormat) + { + this.Image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + this.Imagename = imagename ?? throw new global::System.ArgumentNullException(nameof(imagename)); + this.Size = size; + this.Expire = expire; + this.ImageFormat = imageFormat; + this.N = n; + this.RandomSeed = randomSeed; + this.ResponseFormat = responseFormat; + } + + /// + /// Initializes a new instance of the class. + /// + public VariateImageRequest() + { + } + } +} \ No newline at end of file diff --git a/src/libs/Recraft/openapi.yaml b/src/libs/Recraft/openapi.yaml index 37d8914..3b83012 100644 --- a/src/libs/Recraft/openapi.yaml +++ b/src/libs/Recraft/openapi.yaml @@ -224,6 +224,24 @@ paths: application/json: schema: $ref: '#/components/schemas/GenerateImageResponse' + /v1/images/variateImage: + post: + tags: + - image + summary: Variate Image + operationId: VariateImage + requestBody: + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/VariateImageRequest' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/GenerateImageResponse' /v1/images/vectorize: post: tags: @@ -895,6 +913,28 @@ components: $ref: '#/components/schemas/ImageColor' no_text: type: boolean + VariateImageRequest: + required: + - image + - size + type: object + properties: + expire: + type: boolean + image: + type: string + format: binary + image_format: + $ref: '#/components/schemas/ImageFormat' + n: + type: integer + random_seed: + type: integer + format: uint32 + response_format: + $ref: '#/components/schemas/ResponseFormat' + size: + $ref: '#/components/schemas/ImageSize' securitySchemes: auth0: type: http