()
| 8 | import { cleanupOpenApiDoc } from 'nestjs-zod'; |
| 9 | |
| 10 | async function generateOpenApi() { |
| 11 | // Skip ingest services that require external connections during OpenAPI generation |
| 12 | process.env.SKIP_INGEST_SERVICES = 'true'; |
| 13 | process.env.SHIPSEC_SKIP_MIGRATION_CHECK = 'true'; |
| 14 | |
| 15 | const { AppModule } = await import('../src/app.module'); |
| 16 | |
| 17 | const app = await NestFactory.create(AppModule, { |
| 18 | logger: ['error', 'warn'], |
| 19 | }); |
| 20 | |
| 21 | // Set global prefix to match production |
| 22 | app.setGlobalPrefix('api/v1'); |
| 23 | |
| 24 | const config = new DocumentBuilder() |
| 25 | .setTitle('ShipSec Studio API') |
| 26 | .setDescription('ShipSec backend API specification') |
| 27 | .setVersion('0.1.0') |
| 28 | .addServer('/api/v1', 'API v1') |
| 29 | .build(); |
| 30 | |
| 31 | const document = SwaggerModule.createDocument(app, config); |
| 32 | const cleaned = cleanupOpenApiDoc(document); |
| 33 | const repoRootSpecPath = join(__dirname, '..', '..', 'openapi.json'); |
| 34 | const payload = JSON.stringify(cleaned, null, 2); |
| 35 | |
| 36 | writeFileSync(repoRootSpecPath, payload); |
| 37 | await app.close(); |
| 38 | } |
| 39 | |
| 40 | console.log('Script started'); |
| 41 | generateOpenApi() |
no test coverage detected