From b61f29749794501ba0b0f39b05ffd742219db2ec Mon Sep 17 00:00:00 2001 From: Mathis HERRIOT <197931332+0x485254@users.noreply.github.com> Date: Fri, 16 May 2025 19:10:12 +0200 Subject: [PATCH] feat: add Swagger API documentation setup in main application bootstrap --- backend/src/main.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/backend/src/main.ts b/backend/src/main.ts index a9c1e97..e748dc0 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -1,6 +1,7 @@ import { NestFactory } from '@nestjs/core'; import { ValidationPipe } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; +import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; import { AppModule } from './app.module'; async function bootstrap() { @@ -54,10 +55,22 @@ async function bootstrap() { } // Préfixe global pour les routes API - app.setGlobalPrefix(configService.get('API_PREFIX', 'api')); + const apiPrefix = configService.get('API_PREFIX', 'api'); + app.setGlobalPrefix(apiPrefix); + + // Configuration de Swagger + const config = new DocumentBuilder() + .setTitle('Group Maker API') + .setDescription('API documentation for the Group Maker application') + .setVersion('1.0') + .addBearerAuth() + .build(); + const document = SwaggerModule.createDocument(app, config); + SwaggerModule.setup('api/docs', app, document); const port = configService.get('PORT', 3000); await app.listen(port); console.log(`Application is running on: http://localhost:${port}`); + console.log(`Swagger documentation is available at: http://localhost:${port}/api/docs`); } bootstrap();