Compare commits
3 Commits
f27542e71f
...
67609231d9
| Author | SHA1 | Date | |
|---|---|---|---|
| 67609231d9 | |||
| 90eab514b2 | |||
| 3a98b87ccf |
@@ -29,6 +29,7 @@
|
|||||||
"class-validator": "^0.14.0",
|
"class-validator": "^0.14.0",
|
||||||
"class-transformer": "^0.5.0",
|
"class-transformer": "^0.5.0",
|
||||||
"@asyncapi/cli": "6.0.0",
|
"@asyncapi/cli": "6.0.0",
|
||||||
|
"@asyncapi/html-template": "3.5.6",
|
||||||
"@redocly/cli": "latest"
|
"@redocly/cli": "latest"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ export class ApisController {
|
|||||||
async getDocs(@Param('id') id: string, @Res() res: Response) {
|
async getDocs(@Param('id') id: string, @Res() res: Response) {
|
||||||
const entry = await this.apisService.findOneOrThrow(id);
|
const entry = await this.apisService.findOneOrThrow(id);
|
||||||
if (!entry.htmlPath) throw new NotFoundException('Documentation not generated yet');
|
if (!entry.htmlPath) throw new NotFoundException('Documentation not generated yet');
|
||||||
res.sendFile(entry.htmlPath);
|
const absolutePath = path.resolve(entry.htmlPath);
|
||||||
|
res.sendFile(absolutePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id/yaml')
|
@Get(':id/yaml')
|
||||||
|
|||||||
@@ -50,13 +50,14 @@ export class DocsGenerationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async generateAsyncApi(yamlPath: string, outputDir: string): Promise<void> {
|
private async generateAsyncApi(yamlPath: string, outputDir: string): Promise<void> {
|
||||||
|
/* Chemin local du template — évite l'appel réseau vers registry.npmjs.org */
|
||||||
|
const templatePath = path.join(process.cwd(), 'node_modules', '@asyncapi', 'html-template');
|
||||||
await execFileAsync('asyncapi', [
|
await execFileAsync('asyncapi', [
|
||||||
'generate', 'fromTemplate',
|
'generate', 'fromTemplate',
|
||||||
yamlPath,
|
yamlPath,
|
||||||
'@asyncapi/html-template',
|
templatePath,
|
||||||
'--output', outputDir,
|
'--output', outputDir,
|
||||||
'--no-interactive',
|
'--no-interactive',
|
||||||
'--install',
|
|
||||||
'--force-write',
|
'--force-write',
|
||||||
], { shell: true, env: execEnv });
|
], { shell: true, env: execEnv });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user