-
Couldn't load subscription status.
- Fork 8
fix: resolve parent directory references in OpenAPI bundle to meaningful component names #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ful component names
📊 Test Coverage ReportCurrent Coverage: Coverage Change: ✅ No change Coverage by Package
Generated by GitHub Actions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes handling of parent directory references in OpenAPI bundle component naming to generate meaningful names instead of multiple underscores. The changes improve readability by converting references like ../clean/clean_input.yaml to component names like testdata_clean_clean_input_yaml instead of ___clean_clean_input_yaml.
- Added path normalization functionality to resolve relative paths to meaningful directory names
- Enhanced error handling throughout the component naming pipeline
- Updated test data with comprehensive parent directory reference scenarios
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| openapi/bundle.go | Core implementation with new path normalization and improved error handling |
| openapi/marshalling.go | Updated function signature for better type safety |
| openapi/testdata/test.openapi.yaml | Added Product schema for conflict testing scenarios |
| openapi/testdata/inline/testdata/test.openapi.yaml | New intermediate test file with Product schema |
| openapi/testdata/inline/inline_input.yaml | Added comprehensive parent directory reference test cases and Product schema |
| openapi/testdata/inline/inline_expected.yaml | Updated expected output for inline bundling with new test cases |
| openapi/testdata/inline/bundled_expected.yaml | Updated expected output for filepath-based naming strategy |
| openapi/testdata/inline/bundled_counter_expected.yaml | Updated expected output for counter-based naming strategy |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Improve OpenAPI Bundle Parent Directory Reference Handling
Problem
While investigating issue #50 regarding parent directory references in OpenAPI bundle functionality, we discovered issues with how relative paths like
../xxx.yamlare resolved and converted to component names.Issues Found
Parent directory references were being converted to component names with multiple underscores (
___clean_clean_input_yaml) instead of meaningful directory-based names, making the bundled output less readable and harder to understand.Solution
normalizePathForComponentNamefunction: Usesfilepath.Join,filepath.Clean, andfilepath.Absto resolve relative paths to their actual directory namesgenerateFilePathBasedNameand related functions to properly propagate errors through the call chainChanges
../clean/clean_input.yaml#/components/schemas/User→___clean_clean_input_yaml~components_schemas_User../clean/clean_input.yaml#/components/schemas/User→testdata_clean_clean_input_yaml~components_schemas_UserTesting
Files Changed
openapi/bundle.go- Core implementation improvementsopenapi/marshalling.go- Error handling improvementsThis improvement makes bundled OpenAPI documents more readable and may help address similar issues reported in #50, while ensuring robust handling of relative path references in the bundle functionality.