Skip to content

Fix common base path detection to match only complete path segments#1878

Merged
TharmiganK merged 7 commits intomasterfrom
fix-issue-8574
Jan 30, 2026
Merged

Fix common base path detection to match only complete path segments#1878
TharmiganK merged 7 commits intomasterfrom
fix-issue-8574

Conversation

@TharmiganK
Copy link
Contributor

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts common base path detection in OASModifier so it only matches complete path segments (avoiding false positives like /v2 matching /v2.1), and adds regression tests/resources for version/parameter edge cases.

Changes:

  • Add path-segment-aware prefix checking when computing common base paths.
  • Improve handling of parameterized path segments when determining the non-parameterized prefix.
  • Add new sanitizer test cases and expected outputs covering version mismatches and embedded path parameters.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
openapi-core/src/main/java/io/ballerina/openapi/core/generators/common/OASModifier.java Updates common base path detection to respect path segment boundaries; adjusts parameterized-path handling.
openapi-cli/src/test/java/io/ballerina/openapi/generators/common/OASModifierTests.java Adds regression tests for version mismatch and parameterized segment scenarios.
openapi-cli/src/test/resources/generators/sanitizer/basepath_version_mismatch.yaml New input spec for version-segment mismatch scenario.
openapi-cli/src/test/resources/generators/sanitizer/basepath_with_parameter_1.yaml New input spec where version-like segment contains an embedded parameter.
openapi-cli/src/test/resources/generators/sanitizer/basepath_with_parameter_2.yaml New input spec where an earlier common base path exists despite embedded parameter later.
openapi-cli/src/test/resources/generators/sanitizer/basepath_with_parameter_3.yaml New input spec covering parameterized segment cases with no common base path.
openapi-cli/src/test/resources/generators/sanitizer/expected/modified_basepath_with_parameter_2.yaml Expected output for the “common base path exists” parameter case.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@TharmiganK TharmiganK merged commit a78213b into master Jan 30, 2026
3 of 4 checks passed
@TharmiganK TharmiganK deleted the fix-issue-8574 branch January 30, 2026 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Common path extraction in the align command is not working correctly

2 participants

Comments