Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,6 @@ const { spawn } = require('child_process');
const apisDir = path.join(process.cwd(), 'apis', 'cf');
const distDir = path.join(process.cwd(), 'dist');

async function fixUnresolvedReferences(outputFile, apiVersionDir) {
try {
let content = await fs.readFile(outputFile, 'utf8');

// Fix references that still point to external files
const fixes = [
{ from: /\$ref: \.\.\/components\/schemas\/Job\.yaml/g, to: '#/components/schemas/Job' },
{ from: /\$ref: \.\.\/components\/schemas\/Link\.yaml/g, to: '#/components/schemas/Link' }
];

let hasChanges = false;
for (const fix of fixes) {
if (fix.from.test(content)) {
console.log(`Fixing unresolved reference: ${fix.from.source} -> ${fix.to}`);
content = content.replace(fix.from, `$ref: ${fix.to}`);
hasChanges = true;
}
}

if (hasChanges) {
await fs.writeFile(outputFile, content, 'utf8');
console.log(`Fixed unresolved references in ${outputFile}`);
}
} catch (error) {
console.warn(`Warning: Failed to fix unresolved references in ${outputFile}:`, error.message);
}
}

function runCommand(command, args, options = {}) {
return new Promise((resolve) => {
const cmd = `${command} ${args.join(' ')}`;
Expand Down Expand Up @@ -94,10 +66,6 @@ async function build() {
promises.push(runCommand('redocly', ['bundle', 'openapi.yaml', '-o', path.resolve(outputFile)], {
cwd: apiVersionDir
}).then(async (result) => {
// Post-process the bundled file to fix any remaining unresolved references
if (result.code === 0) {
await fixUnresolvedReferences(outputFile, apiVersionDir);
}
return result;
}));

Expand Down