import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from '../app.module';
import { promises as fs } from 'fs';
import { NestFactory } from '@nestjs/core';
async function bootstrap(): Promise<void> {
  const app = await NestFactory.create(AppModule, {
    preview: true,
  });

  const options = new DocumentBuilder()
    .setTitle('ODMSOpenAPI')
    .setVersion('1.0.0')
    .addBearerAuth({
      type: 'http',
      scheme: 'bearer',
      bearerFormat: 'JWT',
    })
    .build();
  const document = SwaggerModule.createDocument(app, options);
  await fs.writeFile(
    'src/api/odms/openapi.json',
    JSON.stringify(document, null, 0),
  );
}
bootstrap();
