@@ -143,7 +143,15 @@ const postExecutionCode = "// Connection terminated"
143143const indent = 2
144144
145145return (
146- < CloseConnection language= {language} framework= {framework} methodName= {methodName} methodParams= {methodParams} preExecutionCode= {preExecutionCode} postExecutionCode= {postExecutionCode} indent= {indent} / >
146+ < CloseConnection
147+ language= {language}
148+ framework= {framework}
149+ methodName= {methodName}
150+ methodParams= {methodParams}
151+ preExecutionCode= {preExecutionCode}
152+ postExecutionCode= {postExecutionCode}
153+ indent= {indent}
154+ / >
147155);
148156```
149157
@@ -172,7 +180,10 @@ const language = "python"
172180const title = " HoppscotchEchoWebSocketClient"
173181
174182return (
175- < Connect language= {language} title= {title} / >
183+ < Connect
184+ language= {language}
185+ title= {title}
186+ / >
176187)
177188```
178189
@@ -210,7 +221,12 @@ const role = "client"
210221const additionalDependencies = [" import java.util.concurrent.CompletableFuture;" , " import java.time.Duration;" ]
211222
212223return (
213- < DependencyProvider language= {language} framework= {framework} role= {role} additionalDependencies= {additionalDependencies} / >
224+ < DependencyProvider
225+ language= {language}
226+ framework= {framework}
227+ role= {role}
228+ additionalDependencies= {additionalDependencies}
229+ / >
214230)
215231```
216232
@@ -244,17 +260,23 @@ Renders a file header with metadata information such as title, version, protocol
244260import path from " path" ;
245261import { Parser , fromFile } from " @asyncapi/parser" ;
246262
247- const parser = new Parser ();
248- const asyncapi_websocket_query = path .resolve (__dirname , " ../../../helpers/test/__fixtures__/asyncapi-websocket-query.yml" );
249- const language = " javascript"
250-
251- // Parse the AsyncAPI document (async operation)
252- const parseResult = await fromFile (parser, asyncapi_websocket_query).parse ();
253- const parsedAsyncAPIDocument = parseResult .document ;
254-
255- return (
256- < FileHeaderInfo info= {parsedAsyncAPIDocument .info ()} server= {parsedAsyncAPIDocument .servers ().get (" withPathname" )} language= {language} / >
257- )
263+ async function renderFileHeader () {
264+ const parser = new Parser ();
265+ const asyncapi_websocket_query = path .resolve (__dirname , " ../../../helpers/test/__fixtures__/asyncapi-websocket-query.yml" );
266+ const language = " javascript"
267+
268+ // Parse the AsyncAPI document
269+ const parseResult = await fromFile (parser, asyncapi_websocket_query).parse ();
270+ const parsedAsyncAPIDocument = parseResult .document ;
271+
272+ return (
273+ < FileHeaderInfo
274+ info= {parsedAsyncAPIDocument .info ()}
275+ server= {parsedAsyncAPIDocument .servers ().get (" withPathname" )}
276+ language= {language}
277+ / >
278+ )
279+ }
258280```
259281
260282
@@ -299,7 +321,14 @@ const customMethodConfig = {
299321 }
300322};
301323return (
302- < HandleMessage language= {language} methodName= {methodName} methodParams= {methodParams} preExecutionCode= {preExecutionCode} postExecutionCode= {postExecutionCode} customMethodConfig= {customMethodConfig} / >
324+ < HandleMessage
325+ language= {language}
326+ methodName= {methodName}
327+ methodParams= {methodParams}
328+ preExecutionCode= {preExecutionCode}
329+ postExecutionCode= {postExecutionCode}
330+ customMethodConfig= {customMethodConfig}
331+ / >
303332)
304333```
305334
@@ -346,7 +375,18 @@ const methodConfig = {"java" : {methodDocs : methodDocs, methodLogic: methodLogi
346375const framework = " quarkus"
347376
348377return (
349- < MethodGenerator language= {language} methodName= {methodName} methodParams= {methodParams} methodDocs= {methodDocs} methodLogic= {methodLogic} preExecutionCode= {preExecutionCode} postExecutionCode= {postExecutionCode} customMethodConfig= {customMethodConfig} methodConfig= {methodConfig} framework= {framework} / >
378+ < MethodGenerator
379+ language= {language}
380+ methodName= {methodName}
381+ methodParams= {methodParams}
382+ methodDocs= {methodDocs}
383+ methodLogic= {methodLogic}
384+ preExecutionCode= {preExecutionCode}
385+ postExecutionCode= {postExecutionCode}
386+ customMethodConfig= {customMethodConfig}
387+ methodConfig= {methodConfig}
388+ framework= {framework}
389+ / >
350390)
351391```
352392
@@ -382,18 +422,24 @@ Generates and returns an array of model files based on the AsyncAPI document.
382422import path from " path" ;
383423import { Parser , fromFile } from " @asyncapi/parser" ;
384424
385- const parser = new Parser ();
386- const asyncapi_v3_path = path .resolve (__dirname , " ../__fixtures__/asyncapi-v3.yml" );
387-
388- // Parse the AsyncAPI document (async operation)
389- const parseResult = await fromFile (parser, asyncapi_v3_path).parse ();
390- const parsedAsyncAPIDocument = parseResult .document ;
391425
392- const language = " java"
393-
394- return (
395- < Models asyncapi= {parsedAsyncAPIDocument} language= {language} / >
396- )
426+ async function renderModel () {
427+ const parser = new Parser ();
428+ const asyncapi_v3_path = path .resolve (__dirname , " ../__fixtures__/asyncapi-v3.yml" );
429+
430+ // Parse the AsyncAPI document
431+ const parseResult = await fromFile (parser, asyncapi_v3_path).parse ();
432+ const parsedAsyncAPIDocument = parseResult .document ;
433+
434+ const language = " java"
435+
436+ return (
437+ < Models
438+ asyncapi= {parsedAsyncAPIDocument}
439+ language= {language}
440+ / >
441+ )
442+ }
397443```
398444
399445
@@ -428,7 +474,11 @@ const framework = "quarkus"
428474const title = " HoppscotchEchoWebSocketClient"
429475
430476return (
431- < OnClose language= {language} framework= {framework} title= {title} / >
477+ < OnClose
478+ language= {language}
479+ framework= {framework}
480+ title= {title}
481+ / >
432482)
433483```
434484
@@ -511,7 +561,11 @@ const framework = "quarkus"
511561const title = " HoppscotchEchoWebSocketClient"
512562
513563return (
514- < OnOpen language= {language} framework= {framework} title= {title} / >
564+ < OnOpen
565+ language= {language}
566+ framework= {framework}
567+ title= {title}
568+ / >
515569)
516570```
517571
@@ -546,23 +600,30 @@ import path from "path"
546600import { Parser , fromFile } from " @asyncapi/parser" ;
547601import { getQueryParams } from " @asyncapi/generator-helpers" ;
548602
549- const parser = new Parser ();
550- const asyncapi_v3_path = path .resolve (__dirname , " ../__fixtures__/asyncapi-v3.yml" );
551-
552- // Parse the AsyncAPI document (async operation)
553- const parseResult = await fromFile (parser, asyncapi_v3_path).parse ();
554- const parsedAsyncAPIDocument = parseResult .document ;
555-
556- const channels = parsedAsyncAPIDocument .channels ();
557- const queryParamsObject = getQueryParams (channels);
558- const queryParamsArray = queryParamsObject ? Array .from (queryParamsObject .entries ()) : [];
559603
560- const language = " java"
561- const framework = " quarkus"
562-
563- return (
564- < QueryParamsVariables language= {language} framework= {framework} queryParams= {queryParamsArray} / >
565- )
604+ async function renderQueryParamsVariable (){
605+ const parser = new Parser ();
606+ const asyncapi_v3_path = path .resolve (__dirname , " ../__fixtures__/asyncapi-v3.yml" );
607+
608+ // Parse the AsyncAPI document
609+ const parseResult = await fromFile (parser, asyncapi_v3_path).parse ();
610+ const parsedAsyncAPIDocument = parseResult .document ;
611+
612+ const channels = parsedAsyncAPIDocument .channels ();
613+ const queryParamsObject = getQueryParams (channels);
614+ const queryParamsArray = queryParamsObject ? Array .from (queryParamsObject .entries ()) : [];
615+
616+ const language = " java"
617+ const framework = " quarkus"
618+
619+ return (
620+ < QueryParamsVariables
621+ language= {language}
622+ framework= {framework}
623+ queryParams= {queryParamsArray}
624+ / >
625+ )
626+ }
566627```
567628
568629
@@ -603,7 +664,14 @@ const postExecutionCode = "# Post-register operations"
603664const customMethodConfig = { returnType: " int" , openingTag: " {" , closingTag: " }" , indentSize: 2 };
604665
605666return (
606- < RegisterErrorHandler language= {language} methodName= {methodName} methodParams= {methodParams} preExecutionCode= {preExecutionCode} postExecutionCode= {postExecutionCode} customMethodConfig= {customMethodConfig} / >
667+ < RegisterErrorHandler
668+ language= {language}
669+ methodName= {methodName}
670+ methodParams= {methodParams}
671+ preExecutionCode= {preExecutionCode}
672+ postExecutionCode= {postExecutionCode}
673+ customMethodConfig= {customMethodConfig}
674+ / >
607675)
608676```
609677
@@ -643,7 +711,13 @@ const preExecutionCode = "# Pre-register operations"
643711const postExecutionCode = " # Post-register operations"
644712
645713return (
646- < RegisterMessageHandler language= {language} methodName= {methodName} methodParams= {methodParams} preExecutionCode= {preExecutionCode} postExecutionCode= {postExecutionCode} / >
714+ < RegisterMessageHandler
715+ language= {language}
716+ methodName= {methodName}
717+ methodParams= {methodParams}
718+ preExecutionCode= {preExecutionCode}
719+ postExecutionCode= {postExecutionCode}
720+ / >
647721)
648722```
649723
@@ -673,20 +747,26 @@ Generates both static and instance methods for sending messages through WebSocke
673747import path from " path" ;
674748import { Parser , fromFile } from " @asyncapi/parser" ;
675749
676- const parser = new Parser ();
677- const asyncapi_v3_path = path .resolve (__dirname , ' ../__fixtures__/asyncapi-v3.yml' );
678-
679- // Parse the AsyncAPI document (async operation)
680- const parseResult = await fromFile (parser, asyncapi_v3_path).parse ();
681- const parsedAsyncAPIDocument = parseResult .document ;
682-
683- const language = " javascript"
684- const clientName = " AccountServiceAPI"
685- const sendOperations = parsedAsyncAPIDocument .operations ().filterBySend ()
686-
687- return (
688- < SendOperations language= {language} clientName= {clientName} sendOperations= {sendOperations} / >
689- )
750+ async function renderSendOperations (){
751+ const parser = new Parser ();
752+ const asyncapi_v3_path = path .resolve (__dirname , ' ../__fixtures__/asyncapi-v3.yml' );
753+
754+ // Parse the AsyncAPI document
755+ const parseResult = await fromFile (parser, asyncapi_v3_path).parse ();
756+ const parsedAsyncAPIDocument = parseResult .document ;
757+
758+ const language = " javascript"
759+ const clientName = " AccountServiceAPI"
760+ const sendOperations = parsedAsyncAPIDocument .operations ().filterBySend ()
761+
762+ return (
763+ < SendOperations
764+ language= {language}
765+ clientName= {clientName}
766+ sendOperations= {sendOperations}
767+ / >
768+ )
769+ }
690770```
691771
692772
0 commit comments