Reusable Components API

Found an error? Have a suggestion?Edit this page on GitHub

Components

CloseConnectionJSX.Element

Renders a WebSocket close connection method with optional pre- and post-execution logic.

ConnectJSX.Element

Renders a WebSocket connection method for the specified programming language.

DependencyProviderJSX.Element

Renders the top-of-file dependency statements for the selected programming language.

FileHeaderInfoJSX.Element

Renders a file header with metadata information such as title, version, protocol, host, and path.

HandleMessageJSX.Element

Renders a WebSocket message handler method with optional pre- and post-execution logic.

MethodGeneratorJSX.Element

Renders a language-specific formatted method definition.

ModelsArray.<File>

Renders an array of model files based on the AsyncAPI document.

OnCloseJSX.Element

Renders a WebSocket onClose event handler for the specified programming language.

OnErrorJSX.Element

Renders a WebSocket onError event handler for the specified programming language.

OnMessageJSX.Element

Renders a WebSocket onMessage event handler for the specified programming language.

OnOpenJSX.Element

Renders a WebSocket onOpen event handler for the specified programming language.

QueryParamsVariablesArray.<JSX.Element>

Renders query parameter variables code blocks.

AvailableOperationsJSX.Element

Renders a list of AsyncAPI operations with their headers and message examples.

CoreMethodsJSX.Element

Renders a list of core WebSocket client methods for a given target language.

InstallationJSX.Element

Renders the Installation Command for a given language.

MessageExamplesJSX.Element

Renders Message Examples of a given AsyncAPI operation.

OperationHeaderJSX.Element

Renders a header section for a single AsyncAPI operation.

OverviewJSX.Element

Renders an overview section for a WebSocket client. Displays the API description, version, and server URL.

ReadmeJSX.Element

Renders a README.md file for a given AsyncAPI document.

Composes multiple sections (overview, installation, usage, core methods, and available operations) into a single File component based on the provided AsyncAPI document, generator parameters, and target language.

UsageJSX.Element

Renders a usage example snippet for a generated WebSocket client in a given language.

RegisterErrorHandlerJSX.Element

Renders a WebSocket error handler registration method with optional pre- and post-execution logic.

RegisterMessageHandlerJSX.Element

Renders a WebSocket message handler registration method with optional pre- and post-execution logic.

SendOperationsArray.<JSX.Element>

Renders WebSocket send operation methods. Generates both static and instance methods for sending messages through WebSocket connections.

CloseConnection()

Renders a WebSocket close connection method with optional pre- and post-execution logic.

Parameters

NameTypeDescription
propsObjectComponent props.
props.languageLanguageProgramming language used for method formatting.
props.frameworkstringFramework used, if any (e.g., 'quarkus' for Java).
props.methodNamestringName of the method to generate.
props.methodParamsArray.<string>List of parameters for the method.
props.preExecutionCodestringCode to insert before the main function logic.
props.postExecutionCodestringCode to insert after the main function logic.
props.indentnumberIndentation level for the method block.

Returns

  • JSX.Element - A Text component that contains method block with appropriate formatting.

Example

1const language = "java";
2const framework = "quarkus";
3const methodName = "terminateConnection";
4const methodParams = ["String reason"];
5const preExecutionCode = "// About to terminate connection";
6const postExecutionCode = "// Connection terminated";
7const indent = 2;
8
9function renderCloseConnection() {
10  return (
11    <CloseConnection 
12       language={language}
13       framework={framework}
14       methodName={methodName}
15       methodParams={methodParams}
16       preExecutionCode={preExecutionCode} 
17       postExecutionCode={postExecutionCode} 
18       indent={indent} 
19     />
20  );
21}
22
23renderCloseConnection();

Connect()

Renders a WebSocket connection method for the specified programming language.

Parameters

NameTypeDescription
propsObjectComponent props.
props.languageLanguageThe programming language for which to generate connection code.
props.titlestringThe title of the WebSocket server.

Returns

  • JSX.Element - A Text component containing the generated WebSocket connection code for the specified language.

Example

1const language = "python";
2const title = "HoppscotchEchoWebSocketClient";
3
4function renderConnect() {
5  return(
6   <Connect 
7       language={language} 
8       title={title} 
9   />
10  )
11}
12
13renderConnect();

DependencyProvider()

Renders the top-of-file dependency statements for the selected programming language.

Parameters

NameTypeDescription
propsObjectComponent props.
props.languageLanguageThe programming language for which to render dependency statements.
props.frameworkstringThe framework (e.g., 'quarkus' for Java).
props.rolestringThe role (e.g., 'client', 'connector' for Java).
props.additionalDependenciesArray.<string>Optional additional dependencies to include.

Returns

  • JSX.Element - A Text component that contains list of import/require statements.

Example

1const language = "java";
2const framework = "quarkus";
3const role = "client";
4const additionalDependencies = ["import java.util.concurrent.CompletableFuture;", "import java.time.Duration;"];
5
6function renderDependencyProvider() {
7  return (
8    <DependencyProvider 
9       language={language} 
10       framework={framework} 
11       role={role} 
12       additionalDependencies={additionalDependencies} 
13    />
14  )
15}
16renderDependencyProvider();

FileHeaderInfo()

Renders a file header with metadata information such as title, version, protocol, host, and path.

Parameters

NameTypeDescription
propsObjectComponent props.
props.infoObjectInfo object from the AsyncAPI document.
props.serverObjectServer object from the AsyncAPI document.
props.languageLanguageProgramming language used for comment formatting.

Returns

  • JSX.Element - A Text component that contains file header.

Example

1import path from "path";
2import { Parser, fromFile } from "@asyncapi/parser";
3import { FileHeaderInfo } from "@asyncapi/generator-components";
4
5async function renderFileHeader() {
6  const parser = new Parser();
7  const asyncapi_websocket_query = path.resolve(__dirname, "../../../helpers/test/__fixtures__/asyncapi-websocket-query.yml");
8  const language = "javascript";
9  
10  // Parse the AsyncAPI document 
11  const parseResult = await fromFile(parser, asyncapi_websocket_query).parse();
12  const parsedAsyncAPIDocument = parseResult.document;
13  
14  return (
15    <FileHeaderInfo 
16      info={parsedAsyncAPIDocument.info()} 
17      server={parsedAsyncAPIDocument.servers().get("withPathname")} 
18      language={language} 
19    />
20  )
21}
22
23renderFileHeader().catch(console.error);

HandleMessage()

Renders a WebSocket message handler method with optional pre- and post-execution logic.

Parameters

NameTypeDescription
propsObjectComponent props.
props.languageLanguageProgramming language used for method formatting.
props.methodNamestringName of the method to generate.
props.methodParamsArray.<string>List of parameters for the method.
props.preExecutionCodestringCode to insert before the main function logic.
props.postExecutionCodestringCode to insert after the main function logic.
props.customMethodConfigObjectOptional overrides for default method configuration.

Returns

  • JSX.Element - A Text component that contains method block with appropriate formatting.

Example

1const language = "javascript";
2const methodName = "handleMessage";
3const methodParams = ["message","cb"];
4const preExecutionCode = "// Pass the incoming message to all registered message handlers.";
5const postExecutionCode = "// Passed the incoming message to all registered message handlers.";
6const customMethodConfig = {
7  javascript: {
8    methodDocs: "// Method to handle message with callback",
9    methodLogic: "if (cb) cb(message);"
10  }
11};
12
13function renderHandleMessage() {
14  return (
15    <HandleMessage 
16       language={language} 
17       methodName={methodName} 
18       methodParams={methodParams} 
19       preExecutionCode={preExecutionCode} 
20       postExecutionCode={postExecutionCode} 
21       customMethodConfig={customMethodConfig} 
22    />
23  )
24}
25
26renderHandleMessage();

MethodGenerator()

Renders a language-specific formatted method definition.

Parameters

NameTypeDescription
propsObjectComponent props.
props.languageLanguageProgramming language used for method formatting.
props.methodNamestringName of the method.
props.methodParamsArray.<string>Method parameters.
props.methodDocsstringOptional documentation string.
props.methodLogicstringCore method logic.
props.preExecutionCodestringCode before main logic.
props.postExecutionCodestringCode after main logic.
props.indentnumberIndentation for the method block.
props.newLinesnumberNumber of new lines after method.
props.customMethodConfigObjectOptional custom syntax configuration for the current language.
props.methodConfigRecord.<Language, ({methodDocs: (string|undefined), methodLogic: (string|undefined)}|Record.<string, {methodDocs: (string|undefined), methodLogic: (string|undefined)}>)>Language-level or framework-level configuration.
props.frameworkstringFramework name for nested configurations (e.g., 'quarkus' for Java).

Returns

  • JSX.Element - A Text component that contains method block with appropriate formatting.

Example

1const language = "java";
2const methodName = "registerHandler";
3const methodParams = ["Handler handler"];
4const methodDocs = "// Process the input data.";
5const methodLogic = "// TODO: implement";
6const preExecutionCode = "// Before handler registration";
7const postExecutionCode = "// After handler registration";
8const customMethodConfig={ openingTag: "{", closingTag: "}", indentSize: 6 };
9const methodConfig = {"java" : {"quarkus": {methodDocs : methodDocs, methodLogic: methodLogic }}};
10const framework = "quarkus";
11
12function renderMethodGenerator() {
13  return (
14    <MethodGenerator 
15       language={language}
16       methodName={methodName} 
17       methodParams={methodParams} 
18       methodDocs={methodDocs} 
19       methodLogic={methodLogic} 
20       preExecutionCode={preExecutionCode} 
21       postExecutionCode={postExecutionCode} 
22       customMethodConfig={customMethodConfig} 
23       methodConfig={methodConfig} 
24       framework={framework} 
25    />
26  )
27}
28
29renderMethodGenerator();

Models()

Renders an array of model files based on the AsyncAPI document.

Parameters

NameTypeDescription
propsObjectComponent props.
props.asyncapiAsyncAPIDocumentInterfaceParsed AsyncAPI document object.
props.languageLanguageTarget programming language for the generated models.
props.formatFormatNaming format for generated files.
props.presetsObjectCustom presets for the generator instance.
props.constraintsObjectCustom constraints for the generator instance.

Returns

  • Array.&lt;File&gt; - Array of File components with generated model content.

Example

1import path from "path";
2import { Parser, fromFile } from "@asyncapi/parser";
3import { Models } from "@asyncapi/generator-components";
4
5async function renderModel() {
6   const parser = new Parser();
7   const asyncapi_v3_path = path.resolve(__dirname, "../__fixtures__/asyncapi-v3.yml");
8
9    // Parse the AsyncAPI document
10   const parseResult = await fromFile(parser, asyncapi_v3_path).parse();
11   const parsedAsyncAPIDocument = parseResult.document;
12   
13   const language = "java";
14   
15   return (
16     <Models 
17        asyncapi={parsedAsyncAPIDocument} 
18        language={language}
19     />
20   )
21}
22
23renderModel().catch(console.error);

OnClose()

Renders a WebSocket onClose event handler for the specified programming language.

Parameters

NameTypeDescription
propsObjectComponent props.
props.languageLanguageThe programming language for which to generate onClose handler code.
props.frameworkstringFramework variant; required for framework-specific languages (e.g., 'quarkus' for java).
props.titlestringThe title of the WebSocket server.

Returns

  • JSX.Element - A Text component containing the onClose handler code for the specified language.

Example

1const language = "java";
2const framework = "quarkus";
3const title = "HoppscotchEchoWebSocketClient";
4
5function renderOnClose() {
6 return (
7   <OnClose 
8      language={language} 
9      framework={framework} 
10      title={title}  
11   />
12 )
13}
14
15renderOnClose();

OnError()

Renders a WebSocket onError event handler for the specified programming language.

Parameters

NameTypeDescription
propsObjectComponent props.
props.languageLanguageThe programming language for which to generate onError handler code.

Returns

  • JSX.Element - A Text component containing the onError handler code for the specified language.

Example

1const language = "javascript";
2
3function renderOnError() {
4  return (
5    <OnError language={language} />
6  )
7}
8
9renderOnError();

OnMessage()

Renders a WebSocket onMessage event handler for the specified programming language.

Parameters

NameTypeDescription
propsObjectComponent props.
props.languageLanguageThe programming language for which to generate onMessage handler code.

Returns

  • JSX.Element - A Text component containing the onMessage handler code for the specified language.

Example

1const language = "javascript";
2
3function renderOnMessage() {
4  return (
5    <OnMessage language={language} />
6  )
7}
8
9renderOnMessage();

OnOpen()

Renders a WebSocket onOpen event handler for the specified programming language.

Parameters

NameTypeDescription
propsObjectComponent props.
props.languageLanguageThe programming language for which to generate onOpen handler code.
props.frameworkstringOptional framework variant (e.g., 'quarkus' for java).
props.titlestringThe title of the WebSocket server.

Returns

  • JSX.Element - A Text component containing the onOpen handler code for the specified language.

Example

1const language = "java";
2const framework = "quarkus";
3const title = "HoppscotchEchoWebSocketClient";
4
5function renderOnOpen() {
6  return (
7    <OnOpen 
8       language={language} 
9       framework={framework} 
10       title={title} 
11    />
12  )
13}
14
15renderOnOpen();

QueryParamsVariables()

Renders query parameter variables code blocks.

Parameters

NameTypeDescription
propsObjectComponent props.
props.languageLanguageThe target programming language.
props.frameworkstringOptional framework for the language.
props.queryParamsArray.<Array.<string>>Array of query parameters, each represented as [paramName, paramType?].

Returns

  • Array.&lt;JSX.Element&gt; - Array of Text components for each query parameter, or null if queryParams is invalid.

Example

1import path from "path";
2import { Parser, fromFile } from "@asyncapi/parser";
3import { getQueryParams } from "@asyncapi/generator-helpers";
4import { QueryParamsVariables } from "@asyncapi/generator-components";
5
6async function renderQueryParamsVariable(){
7   const parser = new Parser();
8   const asyncapi_v3_path = path.resolve(__dirname, "../__fixtures__/asyncapi-v3.yml");
9   
10   // Parse the AsyncAPI document
11   const parseResult = await fromFile(parser, asyncapi_v3_path).parse();
12   const parsedAsyncAPIDocument = parseResult.document;
13   
14   const channels = parsedAsyncAPIDocument.channels();
15   const queryParamsObject = getQueryParams(channels);
16   const queryParamsArray = queryParamsObject ? Array.from(queryParamsObject.entries()) : [];
17   
18   const language = "java";
19   const framework = "quarkus";
20   
21   return (
22     <QueryParamsVariables 
23         language={language} 
24         framework={framework}   
25         queryParams={queryParamsArray} 
26     />
27   )
28}
29
30renderQueryParamsVariable().catch(console.error);

AvailableOperations()

Renders a list of AsyncAPI operations with their headers and message examples.

Parameters

NameTypeDescription
propsObjectComponent Props
props.operationsArray.<Object>Array of AsyncAPI Operation objects.

Returns

  • JSX.Element - A Component containing rendered operations, or null if no operations are provided

Example

1import path from "path";
2import { Parser, fromFile } from "@asyncapi/parser";
3import { AvailableOperations } from "@asyncapi/generator-components";
4
5async function renderAvailableOperations(){
6  const parser = new Parser();
7  const asyncapi_websocket_query = path.resolve(__dirname, '../../../helpers/test/__fixtures__/asyncapi-websocket-query.yml');
8
9  //parse the AsyncAPI document
10  const parseResult = await fromFile(parser, asyncapi_websocket_query).parse();
11  const parsedAsyncAPIDocument = parseResult.document;
12
13  return (
14   <AvailableOperations operations={parsedAsyncAPIDocument.operations().all()} />
15  )    
16}
17
18renderAvailableOperations().catch(console.error);

CoreMethods()

Renders a list of core WebSocket client methods for a given target language.

Parameters

NameTypeDescription
propsObjectComponent props
props.languageLanguageTarget language used to select method names.

Returns

  • JSX.Element - A Text component that contains a list of core client methods.

Example

1const language = "javascript";
2
3function renderCoreMethods() {
4  return (
5    <CoreMethods language={language} />
6  )
7}
8
9renderCoreMethods();

Installation()

Renders the Installation Command for a given language.

Parameters

NameTypeDescription
propsObjectComponent props
props.languageLanguageThe programming language for which to generate Installation Command.

Returns

  • JSX.Element - A Text component that contains Installation Command.

Example

1const language = "javascript";
2
3function renderInstallation() {
4  return (
5    <Installation language={language} />
6  )
7}
8
9renderInstallation()

MessageExamples()

Renders Message Examples of a given AsyncAPI operation.

Parameters

NameTypeDescription
propsObjectComponent Props
props.operationObjectAn AsyncAPI Operation object.

Returns

  • JSX.Element - A Text component that contains message examples, or null when no examples exist.

Example

1import path from "path";
2import { Parser, fromFile } from "@asyncapi/parser";
3import { MessageExamples } from "@asyncapi/generator-components";
4
5async function renderMessageExamples(){
6  const parser = new Parser();
7  const asyncapi_websocket_query = path.resolve(__dirname, '../../../helpers/test/__fixtures__/asyncapi-websocket-query.yml');
8
9  //parse the AsyncAPI document
10  const parseResult = await fromFile(parser, asyncapi_websocket_query).parse();
11  const parsedAsyncAPIDocument = parseResult.document;
12  const operations = parsedAsyncAPIDocument.operations().all();
13
14  return operations.map((operation) => {
15     return (
16       <MessageExamples operation={operation} />
17     )    
18  });
19}
20
21renderMessageExamples().catch(console.error);

OperationHeader()

Renders a header section for a single AsyncAPI operation.

Parameters

NameTypeDescription
propsObjectComponent properties.
props.operationObjectAn AsyncAPI Operation object.

Returns

  • JSX.Element - A Text component that contains formatted operation header.

Example

1import path from "path";
2import { Parser, fromFile } from "@asyncapi/parser";
3import { OperationHeader } from "@asyncapi/generator-components";
4
5async function renderOperationHeader(){
6  const parser = new Parser();
7  const asyncapi_websocket_query = path.resolve(__dirname, '../../../helpers/test/__fixtures__/asyncapi-websocket-query.yml');
8
9  //parse the AsyncAPI document
10  const parseResult = await fromFile(parser, asyncapi_websocket_query).parse();
11  const parsedAsyncAPIDocument = parseResult.document;
12  const operations = parsedAsyncAPIDocument.operations().all();
13
14  return operations.map((operation) => {
15     return (
16       <OperationHeader operation={operation} />
17     )    
18  });
19}
20
21renderOperationHeader().catch(console.error);

Overview()

Renders an overview section for a WebSocket client. Displays the API description, version, and server URL.

Parameters

NameTypeDescription
propsObjectComponent props
props.infoObjectInfo object from the AsyncAPI document.
props.titlestringTitle from the AsyncAPI document.
props.serverUrlstringServerUrl from a specific server from the AsyncAPI document.

Returns

  • JSX.Element - A Text component that contains the Overview of a Websocket client.

Example

1import path from "path";
2import { Parser, fromFile } from "@asyncapi/parser";
3import { getServer, getServerUrl } from '@asyncapi/generator-helpers';
4import { Overview } from "@asyncapi/generator-components";
5
6async function renderOverview(){
7  const parser = new Parser();
8  const asyncapi_websocket_query = path.resolve(__dirname, '../../../helpers/test/__fixtures__/asyncapi-websocket-query.yml');
9
10  //parse the AsyncAPI document
11  const parseResult = await fromFile(parser, asyncapi_websocket_query).parse();
12  const parsedAsyncAPIDocument = parseResult.document;
13
14  const info = parsedAsyncAPIDocument.info();
15  const title = info.title();
16  const server = getServer(parsedAsyncAPIDocument.servers(), 'withoutPathName');
17  const serverUrl = getServerUrl(server);
18
19  return (
20     <Overview 
21       info={info} 
22       title={title} 
23       serverUrl={serverUrl} 
24     />
25  )
26}
27
28renderOverview().catch(console.error);

Readme()

Renders a README.md file for a given AsyncAPI document.

Composes multiple sections (overview, installation, usage, core methods, and available operations) into a single File component based on the provided AsyncAPI document, generator parameters, and target language.

Parameters

NameTypeDescription
propsObjectComponent props
props.asyncapiAsyncAPIDocumentInterfaceParsed AsyncAPI document instance.
props.paramsObjectGenerator parameters used to customize output
props.languageLanguageTarget language used to render language-specific sections.

Returns

  • JSX.Element - A File component representing the generated README.md.

Example

1import path from "path";
2import { Parser, fromFile } from "@asyncapi/parser";
3import { buildParams } from '@asyncapi/generator-helpers';
4import { Readme } from "@asyncapi/generator-components";
5
6async function renderReadme(){
7  const parser = new Parser();
8  const asyncapi_websocket_query = path.resolve(__dirname, '../../../helpers/test/__fixtures__/asyncapi-websocket-query.yml');
9
10  // parse the AsyncAPI document
11  const parseResult = await fromFile(parser, asyncapi_websocket_query).parse();
12  const parsedAsyncAPIDocument = parseResult.document;
13  const language = "javascript";
14  const config = { clientFileName: 'myClient.js' };
15  const params = buildParams('javascript', config, 'echoServer');
16  
17  return (
18    <Readme 
19      asyncapi={parsedAsyncAPIDocument} 
20      params={params} 
21      language={language}
22    />
23  )
24}
25
26renderReadme().catch(console.error);

Usage()

Renders a usage example snippet for a generated WebSocket client in a given language.

Parameters

NameTypeDescription
propsObjectComponent props
props.clientNamestringThe exported name of the client.
props.clientFileNamestringThe file name where the client is defined.
props.languageLanguageThe target language for which to render the usage snippet

Returns

  • JSX.Element - A Text component containing a formatted usage example snippet.

Example

1const clientName = "MyClient";
2const clientFileName = "myClient.js";
3const language = "javascript";
4
5function renderUsage(){
6  return (
7    <Usage 
8       clientName={clientName} 
9       clientFileName={clientFileName} 
10       language={language}
11    />
12  )
13}
14
15renderUsage();

RegisterErrorHandler()

Renders a WebSocket error handler registration method with optional pre- and post-execution logic.

Parameters

NameTypeDescription
propsObjectComponent props.
props.languageLanguageProgramming language used for method formatting.
props.methodNamestringName of the method to generate.
props.methodParamsArray.<string>List of parameters for the method.
props.preExecutionCodestringCode to insert before the main function logic.
props.postExecutionCodestringCode to insert after the main function logic.
props.customMethodConfigObjectOptional overrides for default method configuration.

Returns

  • JSX.Element - A Text component that contains method block with appropriate formatting.

Example

1const language = "python";
2const methodName = "registerErrorHandler";
3const methodParams = ["self", "handler"];
4const preExecutionCode = "# Pre-register operations";
5const postExecutionCode = "# Post-register operations";
6const customMethodConfig = { returnType: "int", openingTag: "{", closingTag: "}", indentSize: 2};
7
8function renderRegisterErrorHandler() {
9 return (
10   <RegisterErrorHandler 
11      language={language} 
12      methodName={methodName} 
13      methodParams={methodParams} 
14      preExecutionCode={preExecutionCode} 
15      postExecutionCode={postExecutionCode} 
16      customMethodConfig={customMethodConfig}   
17   />
18 )
19}
20
21renderRegisterErrorHandler();

RegisterMessageHandler()

Renders a WebSocket message handler registration method with optional pre- and post-execution logic.

Parameters

NameTypeDescription
propsObjectComponent props.
props.languageLanguageProgramming language used for method formatting.
props.methodNamestringName of the method to generate.
props.methodParamsArray.<string>List of parameters for the method.
props.preExecutionCodestringCode to insert before the main function logic.
props.postExecutionCodestringCode to insert after the main function logic.

Returns

  • JSX.Element - A Text component that contains method block with appropriate formatting.

Example

1const language = "python";
2const methodName = "registerMessageHandler";
3const methodParams = ["self", "handler"];
4const preExecutionCode = "# Pre-register operations";
5const postExecutionCode = "# Post-register operations";
6
7function renderRegisterMessageHandler(){
8  return (
9     <RegisterMessageHandler 
10       language={language} 
11       methodName={methodName} 
12       methodParams={methodParams} 
13       preExecutionCode={preExecutionCode} 
14       postExecutionCode={postExecutionCode} 
15     />
16  )
17}
18
19renderRegisterMessageHandler();

SendOperations()

Renders WebSocket send operation methods. Generates both static and instance methods for sending messages through WebSocket connections.

Parameters

NameTypeDescription
propsObjectComponent props.
props.languageLanguageThe target programming language.
props.sendOperationsArray.<Object>Array of send operations from AsyncAPI document.
props.clientNamestringThe name of the client class.

Returns

  • Array.&lt;JSX.Element&gt; - Array of Text components for static and non-static WebSocket send operation methods, or null if no send operations are provided.

Example

1import path from "path";
2import { Parser, fromFile } from "@asyncapi/parser";
3import { SendOperations } from "@asyncapi/generator-components";
4
5async function renderSendOperations(){
6   const parser = new Parser();
7   const asyncapi_v3_path = path.resolve(__dirname, '../__fixtures__/asyncapi-v3.yml');
8   
9   // Parse the AsyncAPI document
10   const parseResult = await fromFile(parser, asyncapi_v3_path).parse();
11   const parsedAsyncAPIDocument = parseResult.document;
12   
13   const language = "javascript";
14   const clientName = "AccountServiceAPI";
15   const sendOperations = parsedAsyncAPIDocument.operations().filterBySend();
16   
17   return (
18      <SendOperations 
19         language={language} 
20         clientName={clientName} 
21         sendOperations={sendOperations} 
22      />
23   )
24}
25
26renderSendOperations().catch(console.error);
Was this helpful?
Help us improve the docs by adding your contribution.
OR
Github:AsyncAPICreate Issue on GitHub