From 99af9e4a2c642b55ff84fceadf7080556c9e4df0 Mon Sep 17 00:00:00 2001 From: VisualBean Date: Mon, 26 Feb 2024 12:28:03 +0100 Subject: [PATCH] add fallback for primitives --- src/LEGO.AsyncAPI/Models/Any/AsyncApiAny.cs | 5 +++++ test/LEGO.AsyncAPI.Tests/Models/AsyncApiAnyTests.cs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/LEGO.AsyncAPI/Models/Any/AsyncApiAny.cs b/src/LEGO.AsyncAPI/Models/Any/AsyncApiAny.cs index b83d5ba9..8985fed3 100644 --- a/src/LEGO.AsyncAPI/Models/Any/AsyncApiAny.cs +++ b/src/LEGO.AsyncAPI/Models/Any/AsyncApiAny.cs @@ -92,6 +92,11 @@ public static T FromExtensionOrDefault(IAsyncApiExtension extension) /// . public T GetValue() { + if (this.node is JsonValue) + { + return this.node.GetValue(); + } + return JsonSerializer.Deserialize(this.node.ToJsonString()); } diff --git a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiAnyTests.cs b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiAnyTests.cs index 08f1682c..598ef31f 100644 --- a/test/LEGO.AsyncAPI.Tests/Models/AsyncApiAnyTests.cs +++ b/test/LEGO.AsyncAPI.Tests/Models/AsyncApiAnyTests.cs @@ -28,7 +28,7 @@ public void GetValue_ReturnsCorrectConversions() // Assert Assert.AreEqual("string", a.GetValue()); Assert.AreEqual(1, b.GetValue()); - Assert.AreEqual(1.1, c.GetValue()); + Assert.AreEqual(1.1, c.GetValue()); Assert.AreEqual(true, d.GetValue()); Assert.NotNull(e.GetValue()); Assert.IsNotEmpty(f.GetValue>());