import type { INestApplication } from "@nestjs/common";
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";

export function setupSwagger(app: INestApplication): void {
  const documentBuilder = new DocumentBuilder()
    .setTitle("Service User - API Documentation")
    .setDescription("")
    .setVersion("1.0")
    .addBearerAuth();

  const document = SwaggerModule.createDocument(app, documentBuilder.build());
  SwaggerModule.setup("api-documentation", app, document, {
    swaggerOptions: {
      persistAuthorization: true,
    },
    customSiteTitle: 'User - API Documentation'
  });

  console.info(
    `Documentation: http://localhost:${process.env.PORT}/api-documentation`
  );
}
