diff --git a/lib/getMermaidFlowchart.js b/lib/getMermaidFlowchart.js index 6298b11a..b558438b 100644 --- a/lib/getMermaidFlowchart.js +++ b/lib/getMermaidFlowchart.js @@ -17,18 +17,18 @@ function getMermaidFlowchart(metrics) { const service = subscriber.replace(/\s/g,''); if (!visitedServices.includes(service)) { visitedServices.push(service); - mermaidSyntax+=`\n${service}[${subscriber}]`; + mermaidSyntax+=`\n ${service}[${subscriber}]`; } - mermaidSyntax+=`\n${service} -- ${channel} --> server${i}`; + mermaidSyntax+=`\n ${service} -- "${channel}" --> server${i}`; }); operations.pub.forEach((metadata,publisher) => { const service = publisher.replace(/\s/g,''); if (!visitedServices.includes(service)) { visitedServices.push(service); - mermaidSyntax+=`\n${service}[${publisher}]`; + mermaidSyntax+=`\n ${service}[${publisher}]`; } - mermaidSyntax+=`\nserver${i} -- ${channel} --> ${service}`; + mermaidSyntax+=`\n server${i} -- "${channel}" --> ${service}`; }); }); i++; @@ -36,4 +36,4 @@ function getMermaidFlowchart(metrics) { return `graph TD${mermaidSyntax}`; } -module.exports = getMermaidFlowchart; \ No newline at end of file +module.exports = getMermaidFlowchart; diff --git a/test/appRelationsDiscovery_test.js b/test/appRelationsDiscovery_test.js index c315036c..d1a0dc88 100644 --- a/test/appRelationsDiscovery_test.js +++ b/test/appRelationsDiscovery_test.js @@ -7,7 +7,7 @@ chai.use(chaiAsPromised); const {getRelations} = require('../lib/appRelationsDiscovery'); const {getAsyncApiExamples,parseAsyncApiExamples} = require('./testsUtil'); -const outputMermaid = 'graph TD\n server1[(mqtt://localhost:1883)]\nFlightMonitorService[Flight Monitor Service]\nFlightMonitorService -- flight/update --> server1\nFlightNotifierService[Flight Notifier Service]\nserver1 -- flight/update --> FlightNotifierService\nFlightSubscriberService[Flight Subscriber Service]\nFlightSubscriberService -- flight/queue --> server1\nserver1 -- flight/queue --> FlightMonitorService'; +const outputMermaid = 'graph TD\n server1[(mqtt://localhost:1883)]\n FlightMonitorService[Flight Monitor Service]\n FlightMonitorService -- "flight/update" --> server1\n FlightNotifierService[Flight Notifier Service]\n server1 -- "flight/update" --> FlightNotifierService\n FlightSubscriberService[Flight Subscriber Service]\n FlightSubscriberService -- "flight/queue" --> server1\n server1 -- "flight/queue" --> FlightMonitorService'; const outputPlantUML = '@startuml\ntitle Classes - Class Diagram\n\nclass server1 { \n url: mqtt://localhost:1883 \n protocol: mqtt\n}\nFlightMonitorService --|> server1:flight/update\nserver1 --|> FlightNotifierService:flight/update\nFlightSubscriberService --|> server1:flight/queue\nserver1 --|> FlightMonitorService:flight/queue\n@enduml'; const outputReactFlow = [{ id: 'Server1', data: { label: 'mqtt://localhost:1883,mqtt' }, position: { x: 250, y: 5 } }, { id: 'FlightMonitorService', data: { label: 'Flight Monitor Service' }, position: { x: 100, y: 10 } }, { id: 'edge1', source: 'FlightMonitorService', target: 'Server1', animated: true, label: 'flight/update', type: 'edgeType', arrowHeadType: 'arrowclosed' }, { id: 'FlightNotifierService', data: { label: 'Flight Notifier Service' }, position: { x: 100, y: 10 } }, { id: 'edge2', source: 'Server1', target: 'FlightNotifierService', animated: true, label: 'flight/update', type: 'edgeType', arrowHeadType: 'arrowclosed' }, { id: 'FlightSubscriberService', data: { label: 'Flight Subscriber Service' }, position: { x: 100, y: 10 } }, { id: 'edge3', source: 'FlightSubscriberService', target: 'Server1', animated: true, label: 'flight/queue', type: 'edgeType', arrowHeadType: 'arrowclosed' }, { id: 'edge4', source: 'Server1', target: 'FlightMonitorService', animated: true, label: 'flight/queue', type: 'edgeType', arrowHeadType: 'arrowclosed'}]; const flightUpdateSubData = new Map(Object.entries({'Flight Monitor Service': {description: 'Provides updates from a subscribed flight\n',subscribe: {summary: 'Inform about the status of a subscribed flight',message: {summary: 'Provides flight status on arrival and destination',payload: {type: 'object',properties: {user: {type: 'object',properties: {userName: {type: 'string',minimum: 1,description: 'user name',example: 'John Smith','x-parser-schema-id': ''},phoneNumber: {type: 'string',minimum: 5,description: 'phone number where notifications will be received.',example: '+13451235','x-parser-schema-id': ''}},'x-parser-schema-id': ''},departure: {type: 'object',properties: {iataCode: {type: 'string',description: '2 to 3-character IATA carrier code',example: 'MAD','x-parser-schema-id': ''},scheduledDate: {type: 'string',format: 'date-time',description: 'scheduled datetime of the flight, local to the airport.',example: '2020-10-20 19:15','x-parser-schema-id': ''},gate: {type: 'string',description: 'departure gate',example: '2D','x-parser-schema-id': ''},terminal: {type: 'string',description: 'airport terminal',example: '4','x-parser-schema-id': ''}},'x-parser-schema-id': ''},arrival: {type: 'object',properties: {iataCode: {type: 'string',description: '2 to 3-character IATA carrier code',example: 'MAD','x-parser-schema-id': ''},scheduledDate: {type: 'string',format: 'date-time',description: 'scheduled datetime of the flight, local to the airport.',example: '2020-10-20 19:15','x-parser-schema-id': ''},gate: {type: 'string',description: 'departure gate',example: '2D','x-parser-schema-id': ''},terminal: {type: 'string',description: 'airport terminal',example: '4','x-parser-schema-id': ''}},'x-parser-schema-id': ''}},'x-parser-schema-id': ''},'x-parser-original-schema-format': 'application/vnd.aai.asyncapi;version=2.0.0','x-parser-original-payload': {type: 'object',properties: {user: {type: 'object',properties: {userName: {type: 'string',minimum: 1,description: 'user name',example: 'John Smith'},phoneNumber: {type: 'string',minimum: 5,description: 'phone number where notifications will be received.',example: '+13451235'}}},departure: {type: 'object',properties: {iataCode: {type: 'string',description: '2 to 3-character IATA carrier code',example: 'MAD'},scheduledDate: {type: 'string',format: 'date-time',description: 'scheduled datetime of the flight, local to the airport.',example: '2020-10-20 19:15'},gate: {type: 'string',description: 'departure gate',example: '2D'},terminal: {type: 'string',description: 'airport terminal',example: '4'}}},arrival: {type: 'object',properties: {iataCode: {type: 'string',description: '2 to 3-character IATA carrier code',example: 'MAD'},scheduledDate: {type: 'string',format: 'date-time',description: 'scheduled datetime of the flight, local to the airport.',example: '2020-10-20 19:15'},gate: {type: 'string',description: 'departure gate',example: '2D'},terminal: {type: 'string',description: 'airport terminal',example: '4'}}}}},schemaFormat: 'application/vnd.aai.asyncapi;version=2.0.0','x-parser-message-parsed': true,'x-parser-message-name': 'flightStatus'}}}}));