@@ -84,7 +84,7 @@ describe('[integration testing] bundler should ', () => {
8484 } ) ;
8585
8686 test ( 'should be able to bundle specification files in subdirectories and merge them into the base file' , async ( ) => {
87- const object = {
87+ const resultingObject = {
8888 asyncapi : '3.0.0' ,
8989 info : {
9090 title : 'Streetlights MQTT API' ,
@@ -306,7 +306,85 @@ describe('[integration testing] bundler should ', () => {
306306 noValidation : true ,
307307 } ) ;
308308
309- expect ( document . json ( ) ) . toMatchObject ( object ) ;
309+ expect ( document . json ( ) ) . toMatchObject ( resultingObject ) ;
310+ } ) ;
311+
312+ test ( 'should be able to bundle v2 YAML, leaving `x-` properties intact and sorting root props according to AsyncAPI Spec' , async ( ) => {
313+ const resultingObject = {
314+ asyncapi : '2.0.0' ,
315+ 'x-company-attr-1' : 'attr-value-1' ,
316+ 'x-company-attr-2' : 'attr-value-2' ,
317+ id : 'urn:rpc:example:server' ,
318+ defaultContentType : 'application/json' ,
319+ info : {
320+ title : 'RPC Server Example' ,
321+ description : 'This example demonstrates how to define an RPC server.' ,
322+ version : '1.0.0' ,
323+ 'x-company-version' : '1.2.3' ,
324+ } ,
325+ tags : [
326+ {
327+ name : 'my-tag' ,
328+ description : 'tag description' ,
329+ } ,
330+ ] ,
331+ servers : {
332+ production : {
333+ url : 'rabbitmq.example.org' ,
334+ protocol : 'amqp' ,
335+ } ,
336+ } ,
337+ channels : {
338+ '{queue}' : {
339+ parameters : {
340+ queue : {
341+ schema : {
342+ type : 'string' ,
343+ pattern : '^amq\\\\.gen\\\\-.+$' ,
344+ } ,
345+ } ,
346+ } ,
347+ bindings : {
348+ amqp : {
349+ is : 'queue' ,
350+ queue : {
351+ exclusive : true ,
352+ } ,
353+ } ,
354+ } ,
355+ subscribe : {
356+ operationId : 'sendSumResult' ,
357+ bindings : {
358+ amqp : {
359+ ack : true ,
360+ } ,
361+ } ,
362+ message : {
363+ correlationId : {
364+ location : '$message.header#/correlation_id' ,
365+ } ,
366+ payload : {
367+ type : 'object' ,
368+ properties : {
369+ result : {
370+ type : 'number' ,
371+ examples : [ 7 ] ,
372+ } ,
373+ } ,
374+ } ,
375+ } ,
376+ } ,
377+ } ,
378+ } ,
379+ } ;
380+
381+ const files = 'tests/gh-185.yaml' ;
382+
383+ const document = await bundle ( files , {
384+ noValidation : true ,
385+ } ) ;
386+
387+ expect ( document . json ( ) ) . toMatchObject ( resultingObject ) ;
310388 } ) ;
311389} ) ;
312390
0 commit comments