diff --git a/src/Kiota.Builder/OpenApiExtensions/OpenApiLogoExtension.cs b/src/Kiota.Builder/OpenApiExtensions/OpenApiLogoExtension.cs index c987228fab..edd5a2daf5 100644 --- a/src/Kiota.Builder/OpenApiExtensions/OpenApiLogoExtension.cs +++ b/src/Kiota.Builder/OpenApiExtensions/OpenApiLogoExtension.cs @@ -1,20 +1,41 @@ -using Microsoft.OpenApi.Any; +using System; +using Kiota.Builder.Extensions; +using Microsoft.OpenApi; +using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Interfaces; +using Microsoft.OpenApi.Writers; namespace Kiota.Builder.OpenApiExtensions; -public class OpenApiLogoExtension : OpenApiSimpleStringExtension +public class OpenApiLogoExtension : IOpenApiExtension { public static string Name => "x-logo"; - public string? Logo +#pragma warning disable CA1056 + public string? Url +#pragma warning restore CA1056 { get; set; } - protected override string? ValueSelector => Logo; public static OpenApiLogoExtension Parse(IOpenApiAny source) { - return new OpenApiLogoExtension + if (source is not OpenApiObject rawObject) throw new ArgumentOutOfRangeException(nameof(source)); + var extension = new OpenApiLogoExtension(); + if (rawObject.TryGetValue(nameof(Url).ToFirstCharacterLowerCase(), out var url) && url is OpenApiString urlValue) { - Logo = ParseString(source) - }; + extension.Url = urlValue.Value; + } + return extension; + } + + public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion) + { + ArgumentNullException.ThrowIfNull(writer); + if (!string.IsNullOrEmpty(Url)) + { + writer.WriteStartObject(); + writer.WritePropertyName(nameof(Url).ToFirstCharacterLowerCase()); + writer.WriteValue(Url); + writer.WriteEndObject(); + } } } diff --git a/src/Kiota.Builder/Plugins/PluginsGenerationService.cs b/src/Kiota.Builder/Plugins/PluginsGenerationService.cs index 318ab007c7..bc0c3e4bf7 100644 --- a/src/Kiota.Builder/Plugins/PluginsGenerationService.cs +++ b/src/Kiota.Builder/Plugins/PluginsGenerationService.cs @@ -72,7 +72,7 @@ descriptionExtension is OpenApiDescriptionForModelExtension extension && if (OAIDocument.Info.Extensions.TryGetValue(OpenApiLegalInfoUrlExtension.Name, out var legalExtension) && legalExtension is OpenApiLegalInfoUrlExtension legal) legalUrl = legal.Legal; if (OAIDocument.Info.Extensions.TryGetValue(OpenApiLogoExtension.Name, out var logoExtension) && logoExtension is OpenApiLogoExtension logo) - logoUrl = logo.Logo; + logoUrl = logo.Url; if (OAIDocument.Info.Extensions.TryGetValue(OpenApiPrivacyPolicyUrlExtension.Name, out var privacyExtension) && privacyExtension is OpenApiPrivacyPolicyUrlExtension privacy) privacyUrl = privacy.Privacy; }