-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4484 from microsoft/andrueastman/pluginFixes
Remove defaults for plugin types
- Loading branch information
Showing
3 changed files
with
29 additions
and
9 deletions.
There are no files selected for viewing
35 changes: 28 additions & 7 deletions
35
src/Kiota.Builder/OpenApiExtensions/OpenApiLogoExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters