chore: Fix OpenAPI docs script (#17128)

This commit is contained in:
Marc Littlemore
2025-07-08 18:24:32 +01:00
committed by GitHub
parent 57b914dcd9
commit 32fbb5cf6a

View File

@@ -1,5 +1,5 @@
import path from 'path';
import { writeFileSync } from 'fs';
import { writeFileSync, existsSync, mkdirSync } from 'fs';
import { fileURLToPath } from 'url';
import shell from 'shelljs';
import { rawTimeZones } from '@vvo/tzdb';
@@ -18,6 +18,7 @@ generateUserManagementEmailTemplates();
generateTimezoneData();
if (publicApiEnabled) {
createPublicApiDirectory();
copySwaggerTheme();
bundleOpenApiSpecs();
}
@@ -40,6 +41,14 @@ function generateUserManagementEmailTemplates() {
shell.cp(path.resolve(sourceDir, 'n8n-logo.png'), destinationDir);
}
function createPublicApiDirectory() {
const publicApiDirectory = path.resolve(ROOT_DIR, 'dist', 'public-api', 'v1');
if (!existsSync(publicApiDirectory)) {
console.log('Creating directory', publicApiDirectory);
mkdirSync(publicApiDirectory, { recursive: true });
}
}
function copySwaggerTheme() {
const swaggerTheme = {
source: path.resolve(ROOT_DIR, 'src', 'public-api', SPEC_THEME_FILENAME),
@@ -60,7 +69,8 @@ function bundleOpenApiSpecs() {
.forEach((specPath) => {
const distSpecPath = path.resolve(ROOT_DIR, 'dist', specPath);
const command = `pnpm openapi bundle src/${specPath} --output ${distSpecPath}`;
shell.exec(command, { silent: false });
shell.exec(command, { silent: true });
});
}