1515 */
1616
1717import {
18+ _TemplateResolver ,
1819 BuilderStrategy ,
1920 BuildResult ,
2021 BuildTypeContexts ,
@@ -57,6 +58,7 @@ export class ExportRestOperationsGroupStrategy implements BuilderStrategy {
5758
5859async function exportMergedDocument ( config : ExportRestOperationsGroupBuildConfig , buildResult : BuildResult , contexts : BuildTypeContexts ) : Promise < BuildResult > {
5960 const { packageId, version, groupName, format = JSON_EXPORT_GROUP_FORMAT , allowedOasExtensions } = config
61+ const { templateResolver } = contexts . builderContext ( config )
6062
6163 await new MergedDocumentGroupStrategy ( ) . execute ( {
6264 ...config ,
@@ -71,10 +73,10 @@ async function exportMergedDocument(config: ExportRestOperationsGroupBuildConfig
7173 if ( format === HTML_EXPORT_GROUP_FORMAT ) {
7274 const htmlExportDocument = createExportDocument (
7375 `${ getDocumentTitle ( buildResult . merged . filename ) } .${ HTML_EXPORT_GROUP_FORMAT } ` ,
74- await generateHtmlPage ( JSON . stringify ( removeOasExtensions ( buildResult . merged ?. data , allowedOasExtensions ) , undefined , 2 ) , getDocumentTitle ( buildResult . merged . filename ) , packageId , version , false ) ,
76+ await generateHtmlPage ( JSON . stringify ( removeOasExtensions ( buildResult . merged ?. data , allowedOasExtensions ) , undefined , 2 ) , getDocumentTitle ( buildResult . merged . filename ) , packageId , version , templateResolver , false ) ,
7577 )
7678 buildResult . exportDocuments . push ( htmlExportDocument )
77- buildResult . exportDocuments . push ( ...await createCommonStaticExportDocuments ( packageId , version , htmlExportDocument . filename ) )
79+ buildResult . exportDocuments . push ( ...await createCommonStaticExportDocuments ( packageId , version , templateResolver , htmlExportDocument . filename ) )
7880 buildResult . exportFileName = `${ packageId } _${ version } _${ groupName } .zip`
7981 return buildResult
8082 }
@@ -94,6 +96,7 @@ async function exportMergedDocument(config: ExportRestOperationsGroupBuildConfig
9496
9597async function exportReducedDocuments ( config : ExportRestOperationsGroupBuildConfig , buildResult : BuildResult , contexts : BuildTypeContexts ) : Promise < BuildResult > {
9698 const { packageId, version, groupName, format = JSON_EXPORT_GROUP_FORMAT , allowedOasExtensions } = config
99+ const { templateResolver } = contexts . builderContext ( config )
97100
98101 await new DocumentGroupStrategy ( ) . execute ( {
99102 ...config ,
@@ -103,14 +106,14 @@ async function exportReducedDocuments(config: ExportRestOperationsGroupBuildConf
103106
104107 const generatedHtmlExportDocuments : ZippableDocument [ ] = [ ]
105108 const transformedDocuments = await Promise . all ( [ ...buildResult . documents . values ( ) ] . map ( async document => {
106- return await createTransformedDocument ( document , format , packageId , version , generatedHtmlExportDocuments , allowedOasExtensions )
109+ return await createTransformedDocument ( document , format , packageId , version , generatedHtmlExportDocuments , templateResolver , allowedOasExtensions )
107110 } ) )
108111
109112 buildResult . exportDocuments . push ( ...transformedDocuments )
110113
111114 if ( format === HTML_EXPORT_GROUP_FORMAT ) {
112- buildResult . exportDocuments . push ( createExportDocument ( 'index.html' , await generateIndexHtmlPage ( packageId , version , generatedHtmlExportDocuments ) ) )
113- buildResult . exportDocuments . push ( ...await createCommonStaticExportDocuments ( packageId , version ) )
115+ buildResult . exportDocuments . push ( createExportDocument ( 'index.html' , await generateIndexHtmlPage ( packageId , version , generatedHtmlExportDocuments , templateResolver ) ) )
116+ buildResult . exportDocuments . push ( ...await createCommonStaticExportDocuments ( packageId , version , templateResolver ) )
114117 }
115118
116119 if ( buildResult . exportDocuments . length > 1 ) {
@@ -128,14 +131,15 @@ async function createTransformedDocument(
128131 packageId : string ,
129132 version : string ,
130133 generatedHtmlExportDocuments : ZippableDocument [ ] ,
134+ templateResolver : _TemplateResolver ,
131135 allowedOasExtensions ?: OpenApiExtensionKey [ ] ,
132136) : Promise < ZippableDocument > {
133137 const { fileId, type } = document
134138
135139 if ( isRestDocument ( document ) && format === HTML_EXPORT_GROUP_FORMAT ) {
136140 const htmlExportDocument = createExportDocument (
137141 `${ getDocumentTitle ( document . filename ) } .${ HTML_EXPORT_GROUP_FORMAT } ` ,
138- await generateHtmlPage ( JSON . stringify ( removeOasExtensions ( document . data , allowedOasExtensions ) , undefined , 2 ) , getDocumentTitle ( document . filename ) , packageId , version , true ) ,
142+ await generateHtmlPage ( JSON . stringify ( removeOasExtensions ( document . data , allowedOasExtensions ) , undefined , 2 ) , getDocumentTitle ( document . filename ) , packageId , version , templateResolver , true ) ,
139143 )
140144 generatedHtmlExportDocuments . push ( htmlExportDocument )
141145 return htmlExportDocument
0 commit comments