Skip to content

Commit

Permalink
fromextensionordefault
Browse files Browse the repository at this point in the history
  • Loading branch information
VisualBean committed Feb 26, 2024
1 parent 963a931 commit b26964f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/LEGO.AsyncAPI/Models/Any/AsyncApiAny.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public AsyncApiAny(JsonObject node)
/// <typeparam name="T">T.</typeparam>
/// <param name="extension">The extension.</param>
/// <returns><see cref="{T}"/>.</returns>
public static T FromExtension<T>(IAsyncApiExtension extension)
public static T FromExtensionOrDefault<T>(IAsyncApiExtension extension)
{
if (extension is AsyncApiAny any)
{
Expand Down Expand Up @@ -122,7 +122,6 @@ public bool TryGetValue<T>(out T value)
{
try
{

value = this.GetValue<T>();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public void SnsOperationBinding_WithFilledObject_SerializesAndDeserializes()
var binding = new AsyncApiStringReader(settings).ReadFragment<AsyncApiOperation>(actual, AsyncApiVersion.AsyncApi2_0, out _);
var binding2 = new AsyncApiStringReader(settings).ReadFragment<AsyncApiOperation>(expected, AsyncApiVersion.AsyncApi2_0, out _);
binding2.Bindings.First().Value.Extensions.TryGetValue("x-bindingExtension", out IAsyncApiExtension any);
var val = AsyncApiAny.FromExtension<ExtensionClass>(any);
var val = AsyncApiAny.FromExtensionOrDefault<ExtensionClass>(any);

// Assert
Assert.AreEqual(actual, expected);
Expand Down

0 comments on commit b26964f

Please sign in to comment.