Skip to content

Commit

Permalink
Merge pull request #4484 from microsoft/andrueastman/pluginFixes
Browse files Browse the repository at this point in the history
Remove defaults for plugin types
  • Loading branch information
baywet authored Apr 16, 2024
2 parents e23d1ce + 35e1b49 commit 6380cef
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
35 changes: 28 additions & 7 deletions src/Kiota.Builder/OpenApiExtensions/OpenApiLogoExtension.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Plugins/PluginsGenerationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion src/kiota/KiotaPluginCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ internal static Option<List<PluginType>> GetPluginTypeOption(bool isRequired = t
{
typeOption.IsRequired = true;
typeOption.Arity = ArgumentArity.OneOrMore;
typeOption.SetDefaultValue(new List<PluginType> { PluginType.OpenAI });
}
typeOption.AddValidator(x => KiotaHost.ValidateKnownValues(x, "type", Enum.GetNames<PluginType>()));
return typeOption;
Expand Down

0 comments on commit 6380cef

Please sign in to comment.