#!/usr/bin/env node /** * Generates swagger.json from the API DLL using the Swashbuckle CLI. * Does NOT require the API to be running. * * Prerequisites: * dotnet tool install --global Swashbuckle.AspNetCore.Cli --version 6.8.1 * dotnet build src/Strata.ContinuousImprovement.Api/ * * Usage: npm run generate-swagger */ const { execSync } = require('child_process'); const path = require('path'); const fs = require('fs'); const ROOT = path.join(__dirname, '..'); const DLL = path.join(ROOT, 'src/Strata.ContinuousImprovement.Api/bin/Debug/net8.0/Strata.ContinuousImprovement.Api.dll'); const OUTPUT = path.join(ROOT, 'src/Strata.ContinuousImprovement.Web/continuousimprovement/swagger.json'); const DOC_NAME = 'v1'; if (!fs.existsSync(DLL)) { console.log('API DLL not found — building first...'); execSync('dotnet build src/Strata.ContinuousImprovement.Api/ --configuration Debug', { cwd: ROOT, stdio: 'inherit', }); } console.log('Generating swagger.json from API DLL...'); execSync(`swagger tofile --output "${OUTPUT}" "${DLL}" ${DOC_NAME}`, { cwd: ROOT, stdio: 'inherit', }); const size = fs.statSync(OUTPUT).size; console.log(`swagger.json written to ${OUTPUT} (${(size / 1024).toFixed(1)} KB)`);