From 5f2f98eb10c8043c57afa8b8b84ff62a01b94726 Mon Sep 17 00:00:00 2001 From: honnel Date: Thu, 25 Jan 2024 13:01:36 +0100 Subject: [PATCH] Working draft with AsyncAPIDocumentV3 Unfortunatly AsyncAPIDocumentV2 is now broken --- components/TableOfContents.js | 18 ++++++++---------- test/components/TableOfContents.test.js | 23 +++++++++-------------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/components/TableOfContents.js b/components/TableOfContents.js index d63400458..ff0adac1d 100644 --- a/components/TableOfContents.js +++ b/components/TableOfContents.js @@ -17,28 +17,26 @@ export function TableOfContents({ asyncapi }) { }); const operationsList = []; - asyncapi.channels().all().map(channel => { - const channelName = channel.address(); - channel.operations().all().forEach(operation => { - if (operation.action() === 'publish') { + asyncapi.operations().all().map(operation => { + const operationId = operation.id(); + if (operation.action() === 'send') { operationsList.push( - + - PUB {channelName} + PUB {operationId} ); } - if (operation.action() === 'subscribe') { + if (operation.action() === 'receive') { operationsList.push( - + - SUB {channelName} + SUB {operationId} ); } - }); }); return ( diff --git a/test/components/TableOfContents.test.js b/test/components/TableOfContents.test.js index e7531700c..76de0d541 100644 --- a/test/components/TableOfContents.test.js +++ b/test/components/TableOfContents.test.js @@ -1,5 +1,5 @@ import { render } from '@asyncapi/generator-react-sdk'; -import { AsyncAPIDocumentV2 as AsyncAPIDocument } from '@asyncapi/parser'; +import { AsyncAPIDocumentV3 as AsyncAPIDocument } from '@asyncapi/parser'; import { TableOfContents } from '../../components/TableOfContents'; @@ -13,16 +13,14 @@ describe('TableOfContents component', () => { }, channels: { testChannel: { - publish: {}, - subscribe: {}, - }, - 'smartylighting/streetlights/1/0': { - subscribe: {}, - }, - 'smartylighting/streetlights': { - publish: {}, - }, + } }, + operations: { + testOperation: { + action: 'send', + channel: '$ref:#testChannel' + } + } }); const expected = ` ## Table of Contents @@ -32,10 +30,7 @@ describe('TableOfContents component', () => { * [testing](#testing-server) * [canary](#canary-server) * [Operations](#operations) - * [PUB testChannel](#pub-testchannel-operation) - * [SUB testChannel](#sub-testchannel-operation) - * [SUB smartylighting/streetlights/1/0](#sub-smartylightingstreetlights10-operation) - * [PUB smartylighting/streetlights](#pub-smartylightingstreetlights-operation) + * [PUB testOperation](#pub-testOperation) `; const result = render();