Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/LEGO.AsyncAPI/Writers/AsyncApiWriterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,7 @@ public static void WriteRequiredMap<T>(
Action<IAsyncApiWriter, string, T> action)
where T : IAsyncApiElement
{
if (elements != null && elements.Any())
{
writer.WriteMapInternal(name, elements, action);
}
writer.WriteMapInternal(name, elements, action);
}

/// <summary>
Expand Down
31 changes: 31 additions & 0 deletions test/LEGO.AsyncAPI.Tests/AsyncApiDocumentV2Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,5 +1325,36 @@ public void Serializev2_WithBindings_Serializes()

Assert.AreEqual("this mah binding", httpBinding.Headers.Description);
}



[Test]
public void SerializeV2_EmptyChannelObject_DeserializeAndSerializePreserveChannelObject()
{
// Arrange
var spec = """
asyncapi: 2.6.0
info:
title: Spec with missing channel info
description: test description
servers:
production:
url: example.com
protocol: pulsar+ssl
description: test description
channels: { }
""";

var settings = new AsyncApiReaderSettings();
var reader = new AsyncApiStringReader(settings);

// Act
var deserialized = reader.Read(spec, out var diagnostic);
var actual = deserialized.Serialize(AsyncApiVersion.AsyncApi2_0, AsyncApiFormat.Yaml);

// Assert
actual.Should()
.BePlatformAgnosticEquivalentTo(spec);
}
}
}
Loading