u
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import swaggerJsdoc from 'swagger-jsdoc';
|
||||
import { openApiOptions, getOpenApiSpec } from '../src/api/openapiSpec.js';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const root = path.resolve(__dirname, '..');
|
||||
@@ -44,55 +44,7 @@ function isRouteOmitted(method, apiPath) {
|
||||
return OMITTED_ROUTES.has(`${method.toUpperCase()} ${apiPath}`);
|
||||
}
|
||||
|
||||
const options = {
|
||||
definition: {
|
||||
openapi: '3.0.3',
|
||||
info: {
|
||||
title: 'Dash API',
|
||||
version: '1.0.0',
|
||||
description:
|
||||
'Backend API for Dash — Google SSO auth, MSSQL, session cookies.\n\n' +
|
||||
'Browser clients must send cookies (`credentials: \'include\'`). ' +
|
||||
'Sessions use an HTTP-only `token` cookie (`Secure`, `SameSite=Strict`, 24h); HTTPS is required for login.',
|
||||
},
|
||||
servers: [
|
||||
{ url: 'http://localhost:4208/api', description: 'Local default HTTP (PORT / .env)' },
|
||||
{ url: 'https://localhost:8443', description: 'Local default HTTPS (HTTPS_PORT / .env)' },
|
||||
],
|
||||
tags: [
|
||||
{ name: 'Auth', description: 'Google SSO and session' },
|
||||
{ name: 'Health', description: 'Connectivity checks' },
|
||||
{ name: 'POS', description: 'POS bind and sync API (/v1)' },
|
||||
{ name: 'Events', description: 'SSE update signals for live clients' },
|
||||
{ name: 'Article', description: 'Articles under categories' },
|
||||
{ name: 'Category', description: 'Category tree and membership' },
|
||||
{ name: 'Company', description: 'Company CRUD' },
|
||||
{ name: 'CompanySetting', description: 'Company-scoped settings' },
|
||||
{ name: 'Unit', description: 'Company-scoped units of measure' },
|
||||
{ name: 'Brand', description: 'Company-scoped brands' },
|
||||
{ name: 'Supplier', description: 'Company-scoped suppliers (Lieferanten)' },
|
||||
{ name: 'Delivery', description: 'Company-scoped goods receipts (Lieferungen)' },
|
||||
{ name: 'Quote', description: 'Company-scoped quotes (Angebote)' },
|
||||
{ name: 'Order', description: 'Company-scoped sales orders (Aufträge)' },
|
||||
{ name: 'Customergroup', description: 'Company-scoped customer groups' },
|
||||
{ name: 'Entity', description: 'Company-scoped entities, addresses, and contacts' },
|
||||
{ name: 'Image', description: 'Content-addressed AVIF by fullHash' },
|
||||
{ name: 'Posterminal', description: 'Company-scoped POS terminals' },
|
||||
{ name: 'Printer', description: 'Company-scoped receipt and label printers' },
|
||||
{ name: 'Ledger', description: 'Append-only ledger transactions' },
|
||||
{ name: 'Stock', description: 'Manual stock additions and removals' },
|
||||
{ name: 'Warehouse', description: 'Company-scoped warehouses' },
|
||||
{ name: 'Serper', description: 'Serper Google image search and thumbnail streaming' },
|
||||
],
|
||||
},
|
||||
apis: [
|
||||
path.join(root, 'src/api/openapi.js'),
|
||||
path.join(root, 'src/api/routes/**/*.js'),
|
||||
path.join(root, 'src/v1/**/*.js'),
|
||||
],
|
||||
};
|
||||
|
||||
const spec = swaggerJsdoc(options);
|
||||
const spec = getOpenApiSpec(true);
|
||||
|
||||
function ensureDir(dir) {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
@@ -756,5 +708,6 @@ for (const apiPath of paths) {
|
||||
const overviewOperations = operations.filter((op) => !op.omittedFromOverview);
|
||||
fs.writeFileSync(path.join(docsDir, 'routes.md'), renderRoutesOverview(overviewOperations));
|
||||
fs.writeFileSync(path.join(docsDir, 'README.md'), renderReadme(operations));
|
||||
fs.writeFileSync(path.join(docsDir, 'openapi.json'), JSON.stringify(spec, null, 2));
|
||||
|
||||
console.log(`Wrote ${operations.length} route docs + ${overviewOperations.length} in routes.md → docs/api/`);
|
||||
console.log(`Wrote ${operations.length} route docs + ${overviewOperations.length} in routes.md + openapi.json → docs/api/`);
|
||||
|
||||
Reference in New Issue
Block a user