Skip to content

Commit

Permalink
fix: inline channel parameters should not deserialize as references (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
VisualBean authored May 21, 2024
1 parent cf6cf6d commit 7fd3af0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static partial class AsyncApiV2Deserializer
{ "servers", (a, n) => { a.Servers = n.CreateSimpleList(s => s.GetScalarValue()); } },
{ "subscribe", (a, n) => { a.Subscribe = LoadOperation(n); } },
{ "publish", (a, n) => { a.Publish = LoadOperation(n); } },
{ "parameters", (a, n) => { a.Parameters = n.CreateMapWithReference(ReferenceType.Parameter, LoadParameter); } },
{ "parameters", (a, n) => { a.Parameters = n.CreateMap(LoadParameter); } },
{ "bindings", (a, n) => { a.Bindings = LoadChannelBindings(n); } },
};

Expand Down
21 changes: 21 additions & 0 deletions test/LEGO.AsyncAPI.Tests/Models/AsyncApiChannel_Should.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,36 @@
namespace LEGO.AsyncAPI.Tests.Models
{
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using LEGO.AsyncAPI.Bindings.Kafka;
using LEGO.AsyncAPI.Bindings.WebSockets;
using LEGO.AsyncAPI.Models;
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Readers;
using NUnit.Framework;

internal class AsyncApiChannel_Should : TestBase
{
[Test]
public void AsyncApiChannel_WithInlineParameter_DoesNotCreateReference()
{
var input =
"""
parameters:
id:
description: ids
schema:
type: string
enum:
- 08735ae0-6a1a-4578-8b4a-35aa26d15993
- 97845c62-329c-4d87-ad24-4f611b909a10
""";

var channel = new AsyncApiStringReader().ReadFragment<AsyncApiChannel>(input, AsyncApiVersion.AsyncApi2_0, out var _ );
channel.Parameters.First().Value.Reference.Should().BeNull();
}

[Test]
public void AsyncApiChannel_WithWebSocketsBinding_Serializes()
{
Expand Down

0 comments on commit 7fd3af0

Please sign in to comment.