mirror of
https://github.com/jo-inc/camofox-browser.git
synced 2026-10-02 04:14:41 +08:00
Auto-generated OpenAPI 3.0 spec from JSDoc annotations on all 31 routes via swagger-jsdoc. Docs at /docs using swagger-stripey. CI split into parallel unit + e2e jobs (133s → 80s). Supersedes #69. Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
25 lines
715 B
JavaScript
25 lines
715 B
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Generate openapi.json from JSDoc annotations in server.js.
|
|
* Run: node scripts/generate-openapi.js
|
|
*/
|
|
|
|
import { writeFileSync } from 'fs';
|
|
import { dirname, join } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import swaggerJsdoc from 'swagger-jsdoc';
|
|
import { swaggerDefinition } from '../lib/openapi.js';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const root = join(__dirname, '..');
|
|
|
|
const spec = swaggerJsdoc({
|
|
definition: swaggerDefinition,
|
|
apis: [join(root, 'server.js')],
|
|
});
|
|
|
|
const out = join(root, 'openapi.json');
|
|
writeFileSync(out, JSON.stringify(spec, null, 2) + '\n');
|
|
console.log(`Wrote ${Object.keys(spec.paths).length} paths to openapi.json`);
|