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

export function getSwaggerConfig(app: INestApplication) {
  const config = new DocumentBuilder()
    .setTitle('D-menu API')
    .setDescription('API documentation for D-menu backend')
    .setVersion('1.0')
    .addBearerAuth() // optional: for JWT endpoints
    .build();

  const document = SwaggerModule.createDocument(app, config);

  SwaggerModule.setup('docs', app, document, {
    swaggerOptions: {
      persistAuthorization: true,
      displayRequestDuration: true,
      filter: true,
      showExtensions: true,
      docExpansion: 'none',

      // HIDE MODELS / SCHEMAS
      defaultModelsExpandDepth: -1,
      defaultModelExpandDepth: -1,
    },
  });
}
