File tree Expand file tree Collapse file tree 2 files changed +32
-4
lines changed
src/LEGO.AsyncAPI/Writers Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -285,10 +285,7 @@ public static void WriteRequiredMap<T>(
285285 Action < IAsyncApiWriter , string , T > action )
286286 where T : IAsyncApiElement
287287 {
288- if ( elements != null && elements . Any ( ) )
289- {
290- writer . WriteMapInternal ( name , elements , action ) ;
291- }
288+ writer . WriteMapInternal ( name , elements , action ) ;
292289 }
293290
294291 /// <summary>
Original file line number Diff line number Diff line change @@ -1325,5 +1325,36 @@ public void Serializev2_WithBindings_Serializes()
13251325
13261326 Assert . AreEqual ( "this mah binding" , httpBinding . Headers . Description ) ;
13271327 }
1328+
1329+
1330+
1331+ [ Test ]
1332+ public void SerializeV2_EmptyChannelObject_DeserializeAndSerializePreserveChannelObject ( )
1333+ {
1334+ // Arrange
1335+ var spec = """
1336+ asyncapi: 2.6.0
1337+ info:
1338+ title: Spec with missing channel info
1339+ description: test description
1340+ servers:
1341+ production:
1342+ url: example.com
1343+ protocol: pulsar+ssl
1344+ description: test description
1345+ channels: { }
1346+ """ ;
1347+
1348+ var settings = new AsyncApiReaderSettings ( ) ;
1349+ var reader = new AsyncApiStringReader ( settings ) ;
1350+
1351+ // Act
1352+ var deserialized = reader . Read ( spec , out var diagnostic ) ;
1353+ var actual = deserialized . Serialize ( AsyncApiVersion . AsyncApi2_0 , AsyncApiFormat . Yaml ) ;
1354+
1355+ // Assert
1356+ actual . Should ( )
1357+ . BePlatformAgnosticEquivalentTo ( spec ) ;
1358+ }
13281359 }
13291360}
You can’t perform that action at this time.
0 commit comments