Skip to content

Commit 38f2bdc

Browse files
fix: resolve incorrect relative paths in split component references (#175)
Fixes issue where split OpenAPI documents could not be bundled back due to incorrect relative path generation in component $ref references. **Problem:** When splitting an OpenAPI document, components that reference other components (e.g., User schema referencing NotificationPreferences) would generate incorrect relative paths. This caused bundling to fail with errors like: "Cannot resolve: components/schemas/schemas/NotificationPreferences.json" **Root Cause:** In writeComponents(), the convertComponentsToRef() function was passed 'components' as currentFileDir instead of the full path 'components/{type}'. This caused relative path calculation to be incorrect. **Fix:** Changed utils/split.js line 63 to pass the correct directory path: - Before: convertComponentsToRef(..., 'components') - After: convertComponentsToRef(..., path.join('components', componentType)) **Result:** - Split documents now generate correct relative paths - Bundling works correctly for all component references - All existing tests continue to pass 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 068cd25 commit 38f2bdc

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

utils/split.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async function writeComponents(components, options) {
6060
const filePath = path.join(fileDir, `${componentName}.${ext}`);
6161

6262
// Update any component references within components
63-
const updatedComponent = convertComponentsToRef(components[componentType][componentName], ext, 'components');
63+
const updatedComponent = convertComponentsToRef(components[componentType][componentName], ext, path.join('components', componentType));
6464

6565
// Write each component (schema, parameter, etc.) to its own YAML file
6666
await writeFile(filePath, updatedComponent, options);

0 commit comments

Comments
 (0)