From ca698e1c8ab3fe548c742c6d8570c2e9c7152b3b Mon Sep 17 00:00:00 2001 From: "Mamadou Khoussa [028918 DSI/DAC/DIF/DS]" Date: Mon, 1 Dec 2025 22:51:21 +0000 Subject: [PATCH] fix swagger json --- src/main.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index 9959db4..7e29da0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import { ValidationPipe, Logger } from '@nestjs/common'; @@ -15,24 +17,30 @@ async function bootstrap() { app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true })); app.setGlobalPrefix('api/v1'); - // Swagger Configuration + // Swagger Configuration const config = new DocumentBuilder() .setTitle('DCB User Service API') .setDescription('API de gestion des utilisateurs pour le système DCB') .setVersion('1.0') .addTag('users', 'Gestion des utilisateurs') - .addBearerAuth() - //.addServer('http://localhost:3000', 'Développement local') - // .addServer('https://api.example.com', 'Production') + .addBearerAuth() + //.addServer('http://localhost:3000', 'Développement local') + // .addServer('https://api.example.com', 'Production') .build(); const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api-docs', app, document); - app.enableCors({ origin: '*' }) + app.enableCors({ origin: '*' }); + app.getHttpAdapter().get('/api/swagger-json', (req, res) => { + res.json(document); + }); const port = process.env.PORT || 3000; await app.listen(port); logger.log(`Application running on http://localhost:${port}`); - logger.log(`Swagger documentation available at http://localhost:${port}/api/docs`); + logger.log( + `Swagger documentation available at http://localhost:${port}/api-docs`, + ); + console.log(`Swagger docs: http://localhost:${port}/api/swagger-json`); } bootstrap();