1414 * limitations under the License.
1515 */
1616
17- import { BuilderStrategy , BuildResult , BuildTypeContexts , ExportRestDocumentBuildConfig } from '../types'
17+ import {
18+ BuilderStrategy ,
19+ BuildResult ,
20+ BuildTypeContexts ,
21+ ExportDocument ,
22+ ExportRestDocumentBuildConfig ,
23+ } from '../types'
1824import { getDocumentTitle , getSplittedVersionKey } from '../utils'
19- import { createCommonStaticExportDocuments , createSingleFileExportName } from '../utils/export'
25+ import {
26+ createCommonStaticExportDocuments ,
27+ createSingleFileExportName ,
28+ createUnknownExportDocument ,
29+ generateIndexHtmlPage ,
30+ } from '../utils/export'
2031import { createRestExportDocument } from '../apitypes/rest/rest.document'
2132import { FILE_FORMAT_HTML } from '../consts'
2233
@@ -26,17 +37,17 @@ export class ExportRestDocumentStrategy implements BuilderStrategy {
2637 const { rawDocumentResolver, templateResolver, packageResolver } = builderContext ( config )
2738 const { packageId, version : versionWithRevision , documentId, format, allowedOasExtensions } = config
2839 const [ version ] = getSplittedVersionKey ( versionWithRevision )
29-
40+ const generatedHtmlExportDocuments : ExportDocument [ ] = [ ]
3041 const file = await rawDocumentResolver (
3142 versionWithRevision ,
3243 packageId ,
3344 documentId ,
3445 )
3546 const { name : packageName } = await packageResolver ( packageId )
36- buildResult . exportDocuments . push ( await createRestExportDocument ( file . name , await file . text ( ) , format , packageName , version , templateResolver , allowedOasExtensions ) )
37-
47+ buildResult . exportDocuments . push ( await createRestExportDocument ( file . name , await file . text ( ) , format , packageName , version , templateResolver , allowedOasExtensions , generatedHtmlExportDocuments ) )
3848 if ( format === FILE_FORMAT_HTML ) {
39- buildResult . exportDocuments . push ( ...await createCommonStaticExportDocuments ( packageName , version , templateResolver , buildResult . exportDocuments [ 0 ] . filename ) )
49+ buildResult . exportDocuments . push ( ...await createCommonStaticExportDocuments ( packageName , version , templateResolver ) )
50+ buildResult . exportDocuments . push ( createUnknownExportDocument ( 'index.html' , await generateIndexHtmlPage ( packageName , version , generatedHtmlExportDocuments , templateResolver ) ) )
4051 buildResult . exportFileName = createSingleFileExportName ( packageId , version , getDocumentTitle ( file . name ) , 'zip' )
4152 return buildResult
4253 }
0 commit comments